Commit 304e3aa6 authored by Paul McCarthy's avatar Paul McCarthy
Browse files

1. The async.wait function can either be run directly, or can be run on

a new thread.

2. ImageWrapper marks its expand coverage task thread as a daemon.
parent 8381891b
......@@ -180,6 +180,7 @@ class ImageWrapper(notifier.Notifier):
if threaded:
self.__taskThread = async.TaskThread()
self.__taskThread.daemon = True
self.__taskThread.start()
......
......@@ -318,17 +318,31 @@ def wait(threads, task, *args, **kwargs):
instances to finsih (by ``join``ing them), and then runs the given
``task`` via :func:`idle`.
If a ``wx.App`` is not running, this function ``join``s the threads
directly instead of creating a new ``Thread`` to do so.
If the ``direct`` parameter is ``True``, or a ``wx.App`` is not running,
this function ``join``s the threads directly instead of creating a new
``Thread`` to do so.
:arg threads: A ``Thread``, or a sequence of ``Thread`` instances to
join. Elements in the sequence may be ``None``.
:arg threads: A ``Thread``, or a sequence of ``Thread`` instances to
join. Elements in the sequence may be ``None``.
:arg task: The task to run.
:arg task: The task to run once all ``threads`` have completed.
:arg wait_direct: Must be passed as a keyword argument. If ``True``, this
function call will ``join`` all of the ``threads``, and
then call the ``task``. Otherwise (the default), this
function will create a new thread to ``join`` the
``threads``, and will return immediately.
All other arguments are passed to the ``task`` function.
.. note:: This function will not support ``task`` functions which expect
a keyword argument called ``wait_direct``.
"""
direct = kwargs.pop('wait_direct', False)
if not isinstance(threads, collections.Sequence):
threads = [threads]
......@@ -343,7 +357,7 @@ def wait(threads, task, *args, **kwargs):
log.debug('Wait thread scheduling task on idle loop')
idle(task, *args, **kwargs)
if haveWX:
if haveWX and not direct:
thread = threading.Thread(target=joinAll)
thread.start()
return thread
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment