[Twisted-Python] <no subject>
Johann Borck
johann.borck at densedata.com
Mon Sep 19 07:26:00 MDT 2011
On 09/19/2011 02:44 PM, Fabian Rothfuchs wrote:
> Hi Guys,
> [...]
> So I wonder, if you can dynamically feed the reactor with new tasks (I use connectTCP for it), as
> it's not possible to start/stop it on demand (or if there's an alternative approach):
>
Hi,
in general you do [whatever you want] in response to some event, which might be connectionMade,
dataReceived, a periodic call from LoopingCall, a one-shot event from reactor.callLater or any other
API that informs you about certain events. You can take your code, as in your example, and run it
inside one of these callables or another callable you trigger from there. You absolutely do not have
to set up everything before you call reactor.run. Just create a callable (at any time), make sure
that whatever should trigger it gets a reference to it, and then call it whenever appropriate. Also,
look at Deferreds, they provide an API for callbacks, chaining them together and other useful stuff.
regards,
Johann
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20110919/6766ab9b/attachment.html>
More information about the Twisted-Python
mailing list