[Twisted-Python] Twisted-Python Digest, Vol 90, Issue 16

Fabian Rothfuchs fabian.rothfuchs at googlemail.com
Mon Sep 19 14:05:07 MDT 2011


So JP,
 
Having the reactor running in a first thread and *all* the rest in a
second one
is alright, if the second one calls the reactor via callFromThread() ?

Elsewise, I need to find out how to wrap Twisted around Django… hum…

Fabian



On 9/19/11 9:53 PM, "exarkun at twistedmatrix.com"
<exarkun at twistedmatrix.com> wrote:

>On 07:02 pm, fabian.rothfuchs at googlemail.com wrote:
>>Well no, not from multiple threads.
>>I have only two threads � one main thread, which is the Django
>>framework,
>>and one detached
>>thread for the reactor, as the reactor itself would be blocking Django.
>>
>>All Adapters are in Django, and are reaching out to the one reactor in
>>the
>>thread without threading themselves.
>>Is this 'allowed' ?
>
>No.  You can only call Twisted APIs in a single thread.  The thread
>everything will happen in is the one you call reactor.run() in, so
>that's the one you have to call all other APIs in.  There is one
>exception, reactor.callFromThread, which you can call from any thread.
>It lets you schedule another call to happen in the same thread as
>reactor.run was called in.
>
>Jean-Paul
>
>_______________________________________________
>Twisted-Python mailing list
>Twisted-Python at twistedmatrix.com
>http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python






More information about the Twisted-Python mailing list