From 21cf46831524e2c01959dbf6c18074ba0230847f Mon Sep 17 00:00:00 2001 From: Greg Darke Date: Mon, 21 Jul 2008 18:26:32 +1000 Subject: [PATCH] Fixed some more python2.3 issues --- asyncsched.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/asyncsched.py b/asyncsched.py index 428fcf3..cae8713 100644 --- a/asyncsched.py +++ b/asyncsched.py @@ -2,7 +2,7 @@ # 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 @@ -38,6 +38,14 @@ def loop(timeout=30.0, use_poll=False): 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: @@ -48,7 +56,7 @@ def loop(timeout=30.0, use_poll=False): 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) -- 2.39.2