4.7.1. sciexp2.exprun.util.threaded¶
Methods
start(target) |
Decorator to start a function on a separate thread. |
start_args(*args, **kwargs) |
Callable decorator to start a function on a separate thread. |
-
class
threaded(n_jobs=None)¶ Bases:
objectContext manager to run functions in parallel using threads.
Examples
Run two processes in parallel and wait until both are finished:
>>> with step("Running in parallel"), threaded() as t: @t.start def f1(): shell = LocalShell() shell.run(["sleep", "2"]) print("f1")
@t.start def f2():
shell = LocalShell() shell.run([“sleep”, “1”]) print(“f2”)Running in parallel… f2 f1 Running in parallel… done
-
start(target)¶ Decorator to start a function on a separate thread.
-
start_args(*args, **kwargs)¶ Callable decorator to start a function on a separate thread.
Examples
>>> with threaded() as t: @t.start_args(1, b=2) def f(a, b): print(a, b) 1, 2
-