<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Nov 1, 2011, at 4:36 PM, Phil Mayers wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Menlo; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="font-family: monospace; ">One example, we use a tiny script wrapping DeferredSemaphore and<span class="Apple-converted-space">&nbsp;</span><br>t.p.utils.getProcessOutput to parallelise SSH scanning, because<span class="Apple-converted-space">&nbsp;</span><br>ssh-keyscan is (ahem) poorly implemented.<br><br>Maybe I knock up more of these short 20-liners than is common? And<span class="Apple-converted-space">&nbsp;</span><br>typing "reactor, " a lot in them seems a bit, well... retrograde.<br></span></span></blockquote></div><br><div>Hopefully you only need to pass it in at the top level to a few things, not everywhere to everything :).</div><div><br></div><div>For example, with something like twisted.web.client.Agent, you pass the reactor once and then you have an object you can call methods on, you don't need to keep repeating it. &nbsp;If getProcessOutput were a method of a more helpful object, perhaps you'd be able to type 'reactor' a bit less.</div><div><br></div><div>Another possible eventual improvement here is that Twisted include a script-running tool which creates the reactor for you and passes it, either to a specified function or as a magic global in a script. &nbsp;Then you should just pass 'reactor' to the top-level stuff in your script. &nbsp;Sort of like 'twistd' but for one-off things where you don't want to go to the trouble to build a plugin or even a Service.</div><div><br></div><div>As a bonus, such a tool could call 'reactor.run()' for you automatically, eliminating some newbie confusion about when it's appropriate to do that. &nbsp;(And ideally, 'reactor.stop' when some appropriate Deferred is fired, but that gets into more thinking than I want to do about this right now...)</div><div><br></div><div>-glyph</div></body></html>