From c597ad19960a35ad8016ac6ae578ce6ed6bf853d Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauld.mccarthy@gmail.com>
Date: Thu, 4 Aug 2016 10:21:25 +0100
Subject: [PATCH] async.idle can be forced to queue a task even if wx.MainLoop
 is not running.

---
 fsl/utils/async.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/fsl/utils/async.py b/fsl/utils/async.py
index 5b4bd23b8..dd44bb2b4 100644
--- a/fsl/utils/async.py
+++ b/fsl/utils/async.py
@@ -304,6 +304,13 @@ def idle(task, *args, **kwargs):
                        ``name`` is already enqueud, (or is running), the
                        function is not called. Defaults to ``False``.
 
+    :arg alwaysQueue:  Optional. If provided, must be provided as a keyword
+                       argument. If ``True``, and a ``wx.MainLoop`` is not
+                       running, the task is enqueued anyway, under the
+                       assumption that a ``wx.MainLoop`` will be started in
+                       the future.
+
+
     All other arguments are passed through to the task function.
 
     
@@ -333,8 +340,9 @@ def idle(task, *args, **kwargs):
     after        = kwargs.pop('after',        0)
     name         = kwargs.pop('name',         None)
     skipIfQueued = kwargs.pop('skipIfQueued', None)
+    alwaysQueue  = kwargs.pop('alwaysQueue',  False)
 
-    if _haveWX():
+    if alwaysQueue or _haveWX():
         import wx
 
         if not _idleRegistered:
-- 
GitLab