'Determine the longest time the reactor may sleep (waiting on I/O
notification, perhaps) before it must wake up to service a time-related
event.
@return: The maximum number of seconds the reactor may sleep.
@rtype: L{float}'

def timeout(self):

    self._insertNewDelayedCalls()
    if (not self._pendingTimedCalls):
        return None
    delay = (self._pendingTimedCalls[0].time - self.seconds())
    longest = 2147483
    return max(0, min(longest, delay))
