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

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Mon Sep 19 17:04:19 EDT 2011


On 08:05 pm, fabian.rothfuchs at googlemail.com wrote:
>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() ?

Yes, that's fine.  (I think Glyph got you pointed in the right 
direction, I didn't see the next two messages in the thread until after 
I sent my reply.)

Jean-Paul
>Elsewise, I need to find out how to wrap Twisted around Django 26 hum 26
>
>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 ÿFD 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
>
>
>
>_______________________________________________
>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