Skip to content

Commit

Permalink
JJ/TJ: fix for adding timer to waiting process.
Browse files Browse the repository at this point in the history
WIP: Needs some testing
.
  • Loading branch information
thijsj committed Apr 14, 2021
1 parent 8850447 commit 75157b4
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions weightless/io/_reactor.py
Expand Up @@ -37,7 +37,6 @@
from sys import stderr
from traceback import print_exc


class Reactor(object):
"""This Reactor allows applications to be notified of read, write or time events. The callbacks being executed can contain instructions to modify the reader, writers and timers in the reactor. Additions of new events are effective with the next step() call, removals are effective immediately, even if the actual event was already trigger, but the handler wat not called yet."""

Expand Down Expand Up @@ -82,6 +81,7 @@ def addTimer(self, seconds, callback):
timer = Timer(seconds, callback)
self._timers.append(timer)
self._timers.sort(key=_timeKey)
self._writeProcessPipe()
return timer

def removeReader(self, sok):
Expand Down Expand Up @@ -178,10 +178,9 @@ def step(self):
return self

self._prio = (self._prio + 1) % Reactor.MAXPRIO
timeout = -1
if self._timers:
timeout = min(max(0, self._timers[0].time - time()), MAX_TIMEOUT_EPOLL)
else:
timeout = -1

try:
fdEvents = self._epoll.poll(timeout=timeout)
Expand Down

0 comments on commit 75157b4

Please sign in to comment.