# Licensed for distribution under the GPL version 2, check COPYING for details
# asyncore.loop() with delayed function calls
-import asyncore
+import asyncore, select
import heapq
import signal
import time
running = True
oldhandler = signal.signal(signal.SIGTERM, exit)
+ if use_poll:
+ if hasattr(select, 'poll'):
+ poll_fun = asyncore.poll3
+ else:
+ poll_fun = asyncore.poll2
+ else:
+ poll_fun = asyncore.poll
+
while running:
now = time.time()
while tasks and tasks[0].time < now:
if tasks:
t = max(min(t, tasks[0].time - now), 0)
- asyncore.loop(timeout=t, count=1, use_poll=use_poll)
+ poll_fun(timeout=t)
signal.signal(signal.SIGTERM, oldhandler)