Fixed scheduler wait loop
Do fastloop wait until task run time
This commit is contained in:
parent
805f1c0e39
commit
a3606d9e4d
@ -157,16 +157,15 @@ class Scheduler(object):
|
|||||||
if wait <= 0.0:
|
if wait <= 0.0:
|
||||||
newtask = self.addq.get(False)
|
newtask = self.addq.get(False)
|
||||||
else:
|
else:
|
||||||
if wait > 3.0:
|
|
||||||
wait = 3.0
|
|
||||||
newtask = None
|
newtask = None
|
||||||
elapsed = 0
|
|
||||||
while self.run and \
|
while self.run and \
|
||||||
not self.stop.is_set() and \
|
not self.stop.is_set() and \
|
||||||
newtask is None and \
|
newtask is None and \
|
||||||
elapsed < wait:
|
wait > 0:
|
||||||
newtask = self.addq.get(True, self.wait_timeout)
|
try:
|
||||||
elapsed += self.wait_timeout
|
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.
|
except QueueEmpty: # Time to run some tasks, and no new tasks to add.
|
||||||
self.schedule_lock.acquire()
|
self.schedule_lock.acquire()
|
||||||
# select only those tasks which are to be executed now
|
# select only those tasks which are to be executed now
|
||||||
|
Loading…
x
Reference in New Issue
Block a user