ThreadSet
A container for sets of threads.
It provides boilerplate-removing utilities for handling standard library threads.
See Python's threading.Thread
documentation for general information on Python threads.
__init__(*threads)
¶
You can initialize a ThreadSet with any threads you already defined:
class MyCustomThreadSubclass(threading.Thread):
...
threads = ThreadSet(
MyCustomThreadSubclass(...),
threading.Thread(...),
)
threads.start_and_join()
You can create unions of ThreadSets:
readers = ThreadSet(...)
readers.start()
writers = ThreadSet(...)
writers.start()
(readers | writers).join()
You can create a ThreadSet in a function definition, using with_args(),
repeat(), or target:
With ThreadSet.target, function typing
information is kept:
with_args(*args)
classmethod
¶
repeat(times)
classmethod
¶
target(target)
classmethod
¶
start()
¶
Start the threads in this ThreadSet.
Also see Thread.start().
join(timeout=None)
¶
Join the threads in this ThreadSet.
Also see Thread.join().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
float | None
|
The timeout for each individual join to complete. |
None
|
start_and_join(join_timeout=None)
¶
Start the threads in this ThreadSet, then join them.
is_alive()
¶
Call Thread.is_alive()
for each thread in this ThreadSet.