<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif; "><div>That’s a tremendous advice!</div><div>Indeed I was directly calling connectTCP() - I changed it to do like <span class="Apple-style-span" style="font-family: Monaco; font-size: 11px; "> </span></div><div><span class="Apple-style-span" style="font-family: Monaco; font-size: 11px; "><br></span></div><div><span class="Apple-style-span" style="font-family: Monaco; font-size: 11px; ">reactor.<span style="text-decoration: underline">callFromThread</span>(reactor.<span style="text-decoration: underline">connectTCP</span>, host, port, factory, timeout=<span style="color: #8a1407">5</span>)</span></div><div><span class="Apple-style-span" style="font-family: Monaco; font-size: 11px; "><br></span></div><div><span class="Apple-style-span" style="font-family: Monaco; font-size: 11px; ">Thanks!</span></div><div>Fabian</div><div><br></div><div><br></div><span id="OLK_SRC_BODY_SECTION"><div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt"><span style="font-weight:bold">From: </span> Glyph Lefkowitz <<a href="mailto:glyph@twistedmatrix.com">glyph@twistedmatrix.com</a>><br><span style="font-weight:bold">Reply-To: </span> Twisted general discussion <<a href="mailto:twisted-python@twistedmatrix.com">twisted-python@twistedmatrix.com</a>><br><span style="font-weight:bold">Date: </span> Mon, 19 Sep 2011 15:21:34 -0400<br><span style="font-weight:bold">To: </span> Twisted general discussion <<a href="mailto:twisted-python@twistedmatrix.com">twisted-python@twistedmatrix.com</a>><br><span style="font-weight:bold">Subject: </span> Re: [Twisted-Python] Twisted-Python Digest, Vol 90, Issue 16<br></div><div><br></div><div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Sep 19, 2011, at 3:02 PM, Fabian Rothfuchs wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Well no, not from<span class="Apple-converted-space"> </span><u>multiple</u><span class="Apple-converted-space"> </span>threads.</div><div>I have only two threads – one main thread, which is the Django framework, and one detached </div><div>thread for the reactor, as the reactor itself would be blocking Django.</div><div><br></div><div>All Adapters are in Django, and are reaching out to the one reactor in the thread without threading themselves.</div><div>Is this 'allowed' ?</div></blockquote></div><br><div>I guess I should have said "supported", since clearly Python allows it :).</div><div><br></div><div>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.</div><div><br></div><div>-glyph</div><div><br></div></div></div>_______________________________________________
Twisted-Python mailing list
<a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a>
</span></body></html>