summaryrefslogtreecommitdiff
path: root/sleekxmpp/xmlstream/scheduler.py
diff options
context:
space:
mode:
authorAnton Ryzhov <anton@ryzhov.me>2013-06-20 14:03:49 +0400
committerAnton Ryzhov <anton@ryzhov.me>2013-06-20 18:30:07 +0400
commita3606d9e4d3dcdf404949c5293545ac0d9ee5803 (patch)
treef9fb52e9d0c555d5a42180117d28e26bd3733c63 /sleekxmpp/xmlstream/scheduler.py
parent805f1c0e392b29dd335ea6b62b6c08a17a7f6e2c (diff)
downloadslixmpp-a3606d9e4d3dcdf404949c5293545ac0d9ee5803.tar.gz
slixmpp-a3606d9e4d3dcdf404949c5293545ac0d9ee5803.tar.bz2
slixmpp-a3606d9e4d3dcdf404949c5293545ac0d9ee5803.tar.xz
slixmpp-a3606d9e4d3dcdf404949c5293545ac0d9ee5803.zip
Fixed scheduler wait loop
Do fastloop wait until task run time
Diffstat (limited to 'sleekxmpp/xmlstream/scheduler.py')
-rw-r--r--sleekxmpp/xmlstream/scheduler.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/sleekxmpp/xmlstream/scheduler.py b/sleekxmpp/xmlstream/scheduler.py
index 2efa7d1e..e6fae37a 100644
--- a/sleekxmpp/xmlstream/scheduler.py
+++ b/sleekxmpp/xmlstream/scheduler.py
@@ -157,16 +157,15 @@ class Scheduler(object):
if wait <= 0.0:
newtask = self.addq.get(False)
else:
- if wait > 3.0:
- wait = 3.0
newtask = None
- elapsed = 0
while self.run and \
not self.stop.is_set() and \
newtask is None and \
- elapsed < wait:
- newtask = self.addq.get(True, self.wait_timeout)
- elapsed += self.wait_timeout
+ wait > 0:
+ try:
+ newtask = self.addq.get(True, min(wait, self.wait_timeout))
+ except QueueEmpty: # Nothing to add, nothing to do. Check run flags and continue waiting.
+ wait -= self.wait_timeout
except QueueEmpty: # Time to run some tasks, and no new tasks to add.
self.schedule_lock.acquire()
# select only those tasks which are to be executed now