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 <gl...@twistedmatrix.com>
Reply-To:  Twisted general discussion <twisted-python@twistedmatrix.com>
Date:  Mon, 19 Sep 2011 15:21:34 -0400
To:  Twisted general discussion <twisted-python@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@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

Reply via email to