threading.Barrier.reset()

reset() Return the barrier to the default, empty state. Any threads waiting on it will receive the BrokenBarrierError exception. Note that using this function may can require some external synchronization if there are other threads whose state is unknown. If a barrier is broken it may be better to just leave it and create a new one.

threading.Barrier.parties

parties The number of threads required to pass the barrier.

threading.Barrier.n_waiting

n_waiting The number of threads currently waiting in the barrier.

threading.Barrier.broken

broken A boolean that is True if the barrier is in the broken state.

threading.Barrier.abort()

abort() Put the barrier into a broken state. This causes any active or future calls to wait() to fail with the BrokenBarrierError. Use this for example if one of the needs to abort, to avoid deadlocking the application. It may be preferable to simply create the barrier with a sensible timeout value to automatically guard against one of the threads going awry.

threading.Barrier

class threading.Barrier(parties, action=None, timeout=None) Create a barrier object for parties number of threads. An action, when provided, is a callable to be called by one of the threads when they are released. timeout is the default timeout value if none is specified for the wait() method. wait(timeout=None) Pass the barrier. When all the threads party to the barrier have called this function, they are all released simultaneously. If a timeout is provided, it is used in preference to

threading.active_count()

threading.active_count() Return the number of Thread objects currently alive. The returned count is equal to the length of the list returned by enumerate().

The concurrent package

Currently, there is only one module in this package: concurrent.futures – Launching parallel tasks

textwrap.wrap()

textwrap.wrap(text, width=70, **kwargs) Wraps the single paragraph in text (a string) so every line is at most width characters long. Returns a list of output lines, without final newlines. Optional keyword arguments correspond to the instance attributes of TextWrapper, documented below. width defaults to 70. See the TextWrapper.wrap() method for additional details on how wrap() behaves.

textwrap.TextWrapper.wrap()

wrap(text) Wraps the single paragraph in text (a string) so every line is at most width characters long. All wrapping options are taken from instance attributes of the TextWrapper instance. Returns a list of output lines, without final newlines. If the wrapped output has no content, the returned list is empty.