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 #reactor.callLater(1, threading.Thread(target=_listen, args=(self._client,)).start) But this doesn't: #threading.Thread(target=_listen, args=(self._client,)).start() 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 daemonized. I haven't tested that yet but I will now. On Thu, Mar 18, 2010 at 12:08 PM, Andrew Bennetts <and...@bemusement.org> wrote: > (*)·´`·.¸.»ÐëÄdMäñ·´`·.¸.»(*) wrote: >> Hi, >> >> 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 > <http://twistedmatrix.com/documents/current/core/howto/threading.html>. > > 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. > > -Andrew. > > > _______________________________________________ > Twisted-Python mailing list > Twisted-Python@twistedmatrix.com > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python > _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python