diff options
| author | Mattias Andrée <maandree@operamail.com> | 2014-03-07 19:41:48 +0100 |
|---|---|---|
| committer | Mattias Andrée <maandree@operamail.com> | 2014-03-07 19:41:48 +0100 |
| commit | 433a314b254ef3fe0cf73db6f01057b17b91e0e2 (patch) | |
| tree | e84cce37f5ccef0dcc8f1ef24fef90e2ba37fec6 /src/join.py | |
| parent | info: example of ordered and unordered join switches (diff) | |
| download | join-python-433a314b254ef3fe0cf73db6f01057b17b91e0e2.tar.gz join-python-433a314b254ef3fe0cf73db6f01057b17b91e0e2.tar.bz2 join-python-433a314b254ef3fe0cf73db6f01057b17b91e0e2.tar.xz | |
add support for signals in concurrently
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/join.py')
| -rw-r--r-- | src/join.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/join.py b/src/join.py index 76b7445..d057f90 100644 --- a/src/join.py +++ b/src/join.py @@ -217,13 +217,15 @@ def concurrently(*fs): ''' Run a set of functions concurrently and wait for all of them to return - @param fs:*()→void The functions to run + @param fs:*()→(void|join()→...) The functions to run + @return :list<...> The return of each functions, assuming it a signal ''' - ts = [threading.Thread(target = f) for f in fs] - for t in ts: - t.start() - for t in ts: - t.join() + def t(f): + thread = threading.Thread(target = f) + thread.start() + return thread + ts = [f() if isinstance(f, signal) or isinstance(f, puresignal) else t(f) for f in fs] + return [t.join() for t in ts] |
