Re: [Twisted-Python] Best way to trigger a future connection with data

2013-07-22 Thread Laurens Van Houtven
Hi Nick On Mon, Jul 22, 2013 at 10:40 AM, Nick Johnson wrote: > Hi, > > Firstly, thanks for this gist, I had done a few experiments using > endpoints and I think this is definitely the way to go for this code. > Welcome :) > As to the questions: source and destination are parameters for the jo

Re: [Twisted-Python] Best way to trigger a future connection with data

2013-07-22 Thread Nick Johnson
Hi, Firstly, thanks for this gist, I had done a few experiments using endpoints and I think this is definitely the way to go for this code. As to the questions: source and destination are parameters for the job and might change between runs (a function I didn't include for brevity handles computa

Re: [Twisted-Python] Best way to trigger a future connection with data

2013-07-19 Thread Laurens Van Houtven
Hi Nick, I was thinking something along these lines: https://gist.github.com/lvh/67c64042a2be06b7bf7a cheers lvh ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Re: [Twisted-Python] Best way to trigger a future connection with data

2013-07-19 Thread Laurens Van Houtven
Hi Nick, Okay, question and code review time. Why are source and destination arguments to the protocol? Can't they just access it on the factory? It seems that the factory initiates many connections with the same parameters. Is that true? Does it only ever make sense to use the factory to fire m

Re: [Twisted-Python] Best way to trigger a future connection with data

2013-07-19 Thread Nick Johnson
Here's a cut-down version of the code which might be more illustrative: class MyProtocol(Protocol): def __init__(self, s, d): def dataReceived(self, data): def connectionLost(self, reason): reactor.callLater(10, ...) def connectionMade(self): s

Re: [Twisted-Python] Best way to trigger a future connection with data

2013-07-19 Thread Laurens Van Houtven
On Fri, Jul 19, 2013 at 10:19 AM, Nick Johnson wrote: > Thanks lvh, > > I did have to override the buildProtocol method in the Factory but I > then set Protocol.factory to be equal to the Factory (ie, > myprotocol.factory=self). > You could (perhaps should) do this by calling ClientFactory.buildP

Re: [Twisted-Python] Best way to trigger a future connection with data

2013-07-19 Thread Nick Johnson
Thanks lvh, I did have to override the buildProtocol method in the Factory but I then set Protocol.factory to be equal to the Factory (ie, myprotocol.factory=self). I'm still stuck however with what to do when I get more complex than this simple case. For example, I use a callingLoop to call mult

Re: [Twisted-Python] Best way to trigger a future connection with data

2013-07-18 Thread Laurens Van Houtven
Hi Nick, You're pretty much there already. Instantiate a ClientFactory that holds all the necessary state. By default, your protocol will have access to that state through its factory attribute (unless you override the Factory's buildProtocol method). cheers lvh __