Commit 4ada3706 authored by Denis Bilenko's avatar Denis Bilenko

select: avoid creating more than one timer

parent 15a72f83
......@@ -27,14 +27,17 @@ class SelectResult(object):
self.read = []
self.write = []
self.event = Event()
self._timer = None
def update(self, event, evtype):
if evtype & core.EV_READ:
self.read.append(event.arg)
core.timer(0, self.event.set)
if self._timer is None:
self._timer = core.timer(0, self.event.set)
elif evtype & core.EV_WRITE:
self.write.append(event.arg)
core.timer(0, self.event.set)
if self._timer is None:
self._timer = core.timer(0, self.event.set)
# using core.timer(0, ...) to let other active events call update() before Event.wait() returns
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment