Reactors break if a DelayedCall is scheduled with .time = NaN
| Newsgroups | gmane.comp.python.twisted.bugs |
|---|---|
| Message-ID | <[email protected]> |
New submission from bdew <None>:
I'm currently debugging [http://allmydata.org/trac/tahoe/ticket/737 allmydata-tahoe issue #737] the problem there seems to be that somehow a delayed call is scheduled with a time of NaN, this leads to 2 problems in the reactor
1) ReactorBase.runUntilCurrent() won't run that call or anything later
{{{
while self._pendingTimedCalls and (self._pendingTimedCalls[0].time <= now)
}}}
because NaN compared with anything always returns false - this loop never runs and no other calls after the bugged one in self._pendingTimedCalls will ever run.
Also this and any later call will never be removed even if canceled - this loop handles cancelations too.
2) ReactorBase.timeout() returns 0 when that call is in _pendingTimedCalls[0]
This will make the reactor do iterations with 0 timeout, which on most (all?) reactors will lead to 100% CPU usage
Minimal code to demonstrate this bug:
{{{
from twisted.internet import reactor
def foo():
print 'THIS WILL NEVER BE CALLED'
def setup():
reactor.callLater(1,reactor.stop)
reactor.callLater(0,foo).reset(float('nan'))
reactor.callWhenRunning(setup)
reactor.run()
}}}
foo() is never called, the reactor never stops and the process eats 100% CPU, i've tested this on twisted 8.2.0 on windows (select reactor) and linux (poll reactor)
I know setting the timeout to NaN is not something sane to do, but i think twisted should break less horibly when some other bug causes that to happen ;)
----------
Type : defect
Component: core
Keywords :
Priority : normal
Nosy : [email protected]
----------
http://twistedmatrix.com/trac/ticket/3884