[Twisted-Python] reactor.callLater

Andrew Bennetts andrew-twisted at puzzling.org
Mon Jul 14 20:46:56 EDT 2003


On Mon, Jul 14, 2003 at 07:02:55PM -0700, ritchie turner wrote:
> Hi All
> 
> I"m a twisted newbie, and I'd like to know why reactor.callLater
> doesn't seem to work when called from the Factory __init__ method,
> but it does work if I call it from a regular protocol. I'm trying to set up
> a broadcast to all protocalls and am using callLater to schedule a timed
> broadcast.

In general, you should use startFactory for this, rather than __init__, to
support persistence.  If you are using Twisted's plugin infrastructure
(mktap and twistd), then __init__ will be called at mktap time, which is too
early.  If you override the startFactory method instead, it should work --
startFactory is called when the factory is started, rather than when it is
created.

[Hmm... perhaps mktap should do as trial does, and check that the reactor
has no pending timed calls before exiting?  A warning about this sort of
thing could be useful.]

-Andrew.





More information about the Twisted-Python mailing list