Python 3.2+Exceptionsexception
threading.BrokenBarrierError
module exceptions
A Barrier was broken (reset or timed out) while a thread was waiting on it.
Syntax
raise threading.BrokenBarrierError
The key detail: if a single thread leaves wait() on timeout, the barrier breaks for everyone — the other parties get this exception too, not just the late one. An explicit abort() does the same thing on purpose, to unblock threads stuck waiting. The only way back to a usable barrier is reset(), called at a moment when nobody is waiting on it.
Examples
import threading
try:
raise threading.BrokenBarrierError
except threading.BrokenBarrierError as e:
print(type(e).__name__) # → BrokenBarrierError
See also
Open in the full glossarydocs.python.orgReport an inaccuracy