Habit, mostly.  I think it&#39;s a good habit, though.  The reason is that I wanted to make sure the __init__ code completed before the connectTCP was called.  In this case, it doesn&#39;t matter, but if I had a number of things I wanted to do in __init__, it might matter.  Consider:<div>
<br></div><div><div>class MyClientProtocol(Protocol):</div><div>      def connectionMade(self):</div><div>      <span class="Apple-tab-span" style="white-space:pre">        </span>  self.factory.numConnections += 1</div><div><br>
</div><div>class MyClientFactory(Factory):</div><div>      def __init__(self):</div><div>      <span class="Apple-tab-span" style="white-space:pre">        </span>  reactor.connectTCP(host, port, self)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>  self.numConnections = 0</div>
</div><div><br></div><div>&#39;course, I&#39;m sure you&#39;d put reactor.connectTCP *after* the numConnections initializer, but using callWhenRunning ensures that the order doesn&#39;t matter, so it&#39;s one less thing you have to worry about :-)</div>
<div><br></div><div>Jason</div><div><br><div class="gmail_quote">On Wed, Jan 12, 2011 at 4:49 AM,  <span dir="ltr">&lt;<a href="mailto:benjamin.bertrand@lfv.se">benjamin.bertrand@lfv.se</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
One small question about the following code:<br>
Why did you use reactor.callWhenRunning in the __init__ method?<br>
Why not calling directly reactor.connectTCP?<br>
<br>
Cheers,<br>
<div class="im"><br>
Benjamin<br><br></div></blockquote><div> </div><div>-- </div></div>Jason Rennie<br>Research Scientist, ITA Software<br>617-714-2645<br><a href="http://www.itasoftware.com/">http://www.itasoftware.com/</a><br><br>
</div>