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

Fabian Rothfuchs fabian.rothfuchs at googlemail.com
Mon Sep 19 13:40:04 MDT 2011


That¹s a tremendous advice!
Indeed I was directly calling connectTCP() - I changed it to do like

reactor.callFromThread(reactor.connectTCP, host, port, factory, timeout=5)

Thanks!
Fabian


From:  Glyph Lefkowitz <glyph at twistedmatrix.com>
Reply-To:  Twisted general discussion <twisted-python at twistedmatrix.com>
Date:  Mon, 19 Sep 2011 15:21:34 -0400
To:  Twisted general discussion <twisted-python at twistedmatrix.com>
Subject:  Re: [Twisted-Python] Twisted-Python Digest, Vol 90, Issue 16


On Sep 19, 2011, at 3:02 PM, Fabian Rothfuchs 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' ?

I guess I should have said "supported", since clearly Python allows it :).

This is fine - depending very heavily what you mean by "reaching out to the
one reactor".  Are they doing this reaching out via callFromThread (or
something that calls it, like blockingCallFromThread)?  That is OK.  Calling
reactor APIs (like connectTCP, or listenTCP, or callLater) from your Django
thread will break.

-glyph

_______________________________________________ Twisted-Python mailing list
Twisted-Python at twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20110919/0ea0ff73/attachment.html>


More information about the Twisted-Python mailing list