<DIV>Itamar, </DIV>
<DIV>&nbsp;</DIV>
<DIV>This is also problematic. What this code does is limit the number of</DIV>
<DIV>calls that will be made by runUntilCurrent. However, if there's code</DIV>
<DIV>that does a callLater with a delay of 0, it will always execute that.</DIV>
<DIV>&nbsp;</DIV>
<DIV>The problem now is that only callLater's with a delay of 0 will be</DIV>
<DIV>executed. Yes, now the main loop runs fine, but the other timeouts</DIV>
<DIV>are prevented from running. </DIV>
<DIV>&nbsp;</DIV>
<DIV>I'm thinking that what you need to do is to have runUntilCurrent first</DIV>
<DIV>extract all the pending timed calls that it plans to execute, creating</DIV>
<DIV>a sub-list, and then call them. It takes two loops, not one.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Bill<BR><BR><B><I>Itamar Shtull-Trauring &lt;itamar@itamarst.org&gt;</I></B> wrote:</DIV>
<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">On Mon, 2004-05-17 at 10:14, Bill la Forge wrote:<BR><BR>&gt; This means that when you do a callLater with a delay of 0, <BR>&gt; runUntilCurrent will immediately call the delayed function, which then<BR>&gt; calls callLater, and again the delayed function is immediately called,<BR>&gt; etc.<BR><BR>And that's why testImmediateThread failed. Attached is a fixed up patch<BR>that solves that problem.<BR><BR><BR>Index: base.py<BR>===================================================================<BR>--- base.py (revision 10658)<BR>+++ base.py (working copy)<BR>@@ -368,7 +368,11 @@<BR>assert callable(_f), "%s is not callable" % _f<BR>assert sys.maxint &gt;= _seconds &gt;= 0, \<BR>"%s is not greater than or equal to 0 seconds" % (_seconds,)<BR>- tple = DelayedCall(seconds() + _seconds, _f, args, kw,<BR>+ if _seconds == 0:<BR>+ tcc = 0<BR>+ else:<BR>+ tcc = seconds() + _seconds<BR>+ tple =
 DelayedCall(tcc, _f, args, kw,<BR>self._pendingTimedCalls.remove,<BR>self._resetCallLater)<BR>insort(self._pendingTimedCalls, tple)<BR>@@ -416,7 +420,10 @@<BR>count += 1<BR>del self.threadCallQueue[:count]<BR>now = seconds()<BR>- while self._pendingTimedCalls and (self._pendingTimedCalls[-1].time &lt;= now):<BR>+ # make sure we don't run newly added calls, so we don't get into infinite loop<BR>+ numCalls = len(self._pendingTimedCalls)<BR>+ while numCalls and (self._pendingTimedCalls[-1].time &lt;= now):<BR>+ numCalls -= 1<BR>call = self._pendingTimedCalls.pop()<BR>try:<BR>call.called = 1<BR></BLOCKQUOTE><BR><BR>Bill la Forge<br>http://www.geocities.com/laforge49/<p><font face=arial size=-1>
<a href="http://in.rd.yahoo.com/specials/mailtg/*http://yahoo.shaadi.com/india-matrimony/" target="_blank">
<b>Yahoo! India Matrimony</a>:</b> Find your partner 
<a href="http://in.rd.yahoo.com/specials/mailtg2/*http://yahoo.shaadi.com/india-matrimony/community.php" target="_blank">online</a>.</font>