[Twisted-Python] Twisted and python threading
freelancer.c at gmail.com
Thu Mar 18 06:21:47 EDT 2010
Hi thanks for the reply,
I have a separate module that doesn't/shouldn't depend on Twisted, and
this module is begin called from a Twisted application, and it needs
to spawn a thread the thread doesn't call anything within Twisted, the
problem is when I call start() the thread doesn't run, but If I import
Twisted into this module and spawn the thread from reactor.callLater()
it works just fine, that is, this code works :
#from twisted.internet import reactor
But this doesn't:
I asked on #twisted and someone said that something about my
application running as daemon and that destroys all threads spawned
before that, and that I should spawn the thread *after* it's fully
I haven't tested that yet but I will now.
On Thu, Mar 18, 2010 at 12:08 PM, Andrew Bennetts <andrew at bemusement.org> wrote:
> (*)·´`·.¸.»ÐëÄdMäñ·´`·.¸.»(*) wrote:
>> I'm trying to spawn a threading.Thread from a Twisted application, but
>> the thread won't start unless I schedule the the code with
>> reactor.callLater(), any Ideas ?
> Twisted doesn't affect threading.Thread at all.
> You haven't given much detail, so my best guess is that you are calling
> Twisted APIs from a non-reactor thread. Twisted's APIs are generally
> *not* thread-safe, so that will give undefined behaviour (like nothing
> happening when it should). Basically the only API you should use is
> reactor.callFromThread. See
> If that's not your problem, you'll have to elaborate more on what your
> problem (like what precisely you mean by “thread won't start”) and how
> to reproduce it.
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
More information about the Twisted-Python