From e64eb2599777c4fd25d0d425ae3d4af0d93b88bf Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauld.mccarthy@gmail.com> Date: Thu, 4 Aug 2016 14:49:22 +0100 Subject: [PATCH] If async idle loop re-queues a task (with after > 0) it doesn't immediatelly re-run the idle loop. --- fsl/utils/async.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fsl/utils/async.py b/fsl/utils/async.py index dd44bb2b4..01ea1778a 100644 --- a/fsl/utils/async.py +++ b/fsl/utils/async.py @@ -244,8 +244,9 @@ def _wxIdleLoop(ev): _idleTimer.Start(_idleCallRate, wx.TIMER_ONE_SHOT) return - now = time.time() - elapsed = now - task.schedtime + now = time.time() + elapsed = now - task.schedtime + queueSizeOffset = 0 # Has enouggh time elapsed # since the task was scheduled? @@ -254,6 +255,7 @@ def _wxIdleLoop(ev): log.debug('Re-queueing function ({}) on wx idle ' 'loop'.format(getattr(task.task, '__name__', '<unknown>'))) _idleQueue.put_nowait(task) + queueSizeOffset = 1 # Has the task timed out? elif task.timeout == 0 or (elapsed < task.timeout): @@ -265,7 +267,7 @@ def _wxIdleLoop(ev): if task.name is not None: _idleQueueSet.discard(task.name) - if _idleQueue.qsize() > 0: + if _idleQueue.qsize() > queueSizeOffset: ev.RequestMore() else: _idleTimer.Start(_idleCallRate, wx.TIMER_ONE_SHOT) -- GitLab