[Twisted-Python] Reactor callback from the wrong thread
exarkun at divmod.com
Wed May 27 11:43:22 EDT 2009
On Wed, 27 May 2009 15:08:49 +0200, Lars Ivar Igesund <larsivi at gmail.com> wrote:
>I have an issue where the reactor calls the callback from a different
>thread than the one the reactor is running in.
Generally speaking, the only callbacks the reactor invokes are protocol
methods (like dataReceived and connectionLost) and timed events (things
you pass to reactor.callLater). It always calls these in the thread it
is running in. What callbacks are you seeing be invoked in the "wrong"
>What can cause this and how may I debug it? AFAIK, PyFit does not use
>twisted or threading at all, and we only have two simple background
>threads our selves in addition to the one running the trap deamon.
The most likely explanation is that your code (perhaps by way of PyFit,
I'm not sure -- I've never used PyFit) is calling a Twisted API from a
thread other than the reactor thread. So, examine all the places you
call Twisted APIs (including APIs in twistedsnmp which may call Twisted
APIs) and make sure they're only run in the reactor thread.
More information about the Twisted-Python