Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
...@@ -180,6 +180,7 @@ class ImageWrapper(notifier.Notifier): ...@@ -180,6 +180,7 @@ class ImageWrapper(notifier.Notifier):
if threaded: if threaded:
self.__taskThread = async.TaskThread() self.__taskThread = async.TaskThread()
self.__taskThread.daemon = True
self.__taskThread.start() self.__taskThread.start()
......
...@@ -318,17 +318,31 @@ def wait(threads, task, *args, **kwargs): ...@@ -318,17 +318,31 @@ def wait(threads, task, *args, **kwargs):
instances to finsih (by ``join``ing them), and then runs the given instances to finsih (by ``join``ing them), and then runs the given
``task`` via :func:`idle`. ``task`` via :func:`idle`.
If a ``wx.App`` is not running, this function ``join``s the threads If the ``direct`` parameter is ``True``, or a ``wx.App`` is not running,
directly instead of creating a new ``Thread`` to do so. 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 :arg threads: A ``Thread``, or a sequence of ``Thread`` instances to
join. Elements in the sequence may be ``None``. 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. 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): if not isinstance(threads, collections.Sequence):
threads = [threads] threads = [threads]
...@@ -343,7 +357,7 @@ def wait(threads, task, *args, **kwargs): ...@@ -343,7 +357,7 @@ def wait(threads, task, *args, **kwargs):
log.debug('Wait thread scheduling task on idle loop') log.debug('Wait thread scheduling task on idle loop')
idle(task, *args, **kwargs) idle(task, *args, **kwargs)
if haveWX: if haveWX and not direct:
thread = threading.Thread(target=joinAll) thread = threading.Thread(target=joinAll)
thread.start() thread.start()
return thread return thread
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment