<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; ">Hi Guys,</div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; "><br></div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; ">I'm relatively new to Twisted (as the most questioners I guess).&nbsp;</div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; ">Without providing tons of distracting details, this is where I'm stuck w/ Twisted:</div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; "><br></div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; ">I currently build a server application that consists of a set of client adapters, which (among others) use Telnet as transport protocol &#8211; so I chose to use Twisted to write the client.</div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; ">I already have all clients in place in an autarkic Twisted implementation and it works just fine &#8211; thus, the crux is to get those autarkic snippets under one reactor-hood.</div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; ">As this application should ideally server forever, stopping the reactor would mean to stop the whole application, which conflicts with it's ideology.</div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; ">During the night, the application will be fed new tasks &#8211; depending on what those tasks are, the application needs to run specific workflows using different adapters (and protocols).</div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; "><br></div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; ">Having said this, when starting the application (and hence the reactor), I'm not yet aware of the following:</div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; "><span class="Apple-tab-span" style="white-space:pre">        </span>- which adapters I will need during</div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; "><span class="Apple-tab-span" style="white-space:pre">        </span>- when the connections are triggered</div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; "><br></div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; ">But all implementation examples and documentations I've found expect those information to be present and provided to the reactor, prior to it's run():</div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; "><br></div><div style="color: rgb(0, 0, 0); "><p style="font-family: Calibri, sans-serif; font-size: 14px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span style="color: #3c00ff">for</span> host <span style="color: #3c00ff">in</span> hosts:</p>
<p style="font-family: Calibri, sans-serif; font-size: 14px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">&nbsp; &nbsp; host, port = (host, <span style="color: #8a1407">23</span>)</p>
<p style="font-family: Calibri, sans-serif; font-size: 14px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">&nbsp; &nbsp; d = defer.Deferred()</p>
<p style="font-family: Calibri, sans-serif; font-size: 14px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">&nbsp; &nbsp; <span style="color: #3c00ff">from</span> twisted.internet <span style="color: #3c00ff">import</span> <span style="text-decoration: underline">reactor</span></p>
<p style="font-family: Calibri, sans-serif; font-size: 14px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(203, 203, 203); "><span class="Apple-style-span" style="color: rgb(0, 0, 0); ">&nbsp; &nbsp; factory = S12ClientFactory(d, username=<span style="color: #34b900">'root'</span>, password=<span style="color: #34b900">'</span><span style="text-decoration: underline ; color: #34b900">admin</span><span style="color: #34b900">'</span>)</span></p>
<p style="font-family: Calibri, sans-serif; font-size: 14px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">&nbsp; &nbsp; Connection =&nbsp;reactor.<span style="text-decoration: underline">connectTCP</span>(host, port, factory, timeout=<span style="color: #8a1407">5</span>)</p>
<p style="font-family: Calibri, sans-serif; font-size: 14px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">&nbsp; &nbsp; d.addCallbacks(success, error)</p>
<p style="font-family: Calibri, sans-serif; font-size: 14px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">&nbsp; &nbsp; d.addBoth(logout)</p><p style="font-family: Calibri, sans-serif; font-size: 14px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">reactor.run()</p></div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; "><br></div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; ">So I wonder, if you can dynamically feed the reactor with new tasks (I use connectTCP for it), as it's not possible to start/stop it on demand (or if there's an alternative approach):</div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; "><br></div><div style="font-family: Calibri, sans-serif; font-size: 14px; "><p style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-style-span" style="font-size: 14px; font-family: Calibri, sans-serif; "><p style="font-family: Calibri, sans-serif; font-size: 14px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span style="color: rgb(60, 0, 255); ">from</span>&nbsp;twisted.internet&nbsp;<span style="color: rgb(60, 0, 255); ">import</span>&nbsp;<span style="text-decoration: underline; ">reactor</span></p></span></p><p style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span style="color: rgb(60, 0, 255); "><span class="Apple-style-span" style="color: rgb(0, 0, 0); ">reactor.run()</span></span></p><p style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span style="color: rgb(60, 0, 255); ">for</span>&nbsp;host&nbsp;<span style="color: rgb(60, 0, 255); ">in</span>&nbsp;hosts:</p><p style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">&nbsp; &nbsp;&nbsp;host, port = (host,&nbsp;<span style="color: rgb(138, 20, 7); ">23</span>)</p><p style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">&nbsp; &nbsp;&nbsp;d = defer.Deferred()</p><p style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">&nbsp; &nbsp; factory = S12ClientFactory(d, username=<span style="color: rgb(52, 185, 0); ">'root'</span>, password=<span style="color: rgb(52, 185, 0); ">'</span><span style="text-decoration: underline; color: rgb(52, 185, 0); ">admin</span><span style="color: rgb(52, 185, 0); ">'</span>)</p><p style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">&nbsp; &nbsp;&nbsp;Connection =&nbsp;reactor.<span style="text-decoration: underline; ">connectTCP</span>(host, port, factory, timeout=<span style="color: rgb(138, 20, 7); ">5</span>)</p><p style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">&nbsp; &nbsp;&nbsp;d.addCallbacks(success, error)</p><p style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">&nbsp; &nbsp; d.addBoth(logout)</p><p style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><br></p></div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; "><div style="font-family: Calibri, sans-serif; font-size: 14px; ">If I try to do so,<span style="font-family: Courier; ">&nbsp;connection.state</span> never leaves 'connecting' and I cannot see any traffic going through the wire on the TCPDump?</div><div style="font-family: Calibri, sans-serif; font-size: 14px; ">I'd really appreciate any hints, as I'm feeling a bit lost :-)</div></div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; "><br></div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; ">Thanks</div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; ">Fabian</div></body></html>