Create a barrier, initialised to 'parties' threads. 'action' is a callable which, when supplied, will be called by one of the threads after they have all entered the barrier and just prior to releasing them all. If a 'timeout' is provided, it is used as the defa
(self, parties, action=None, timeout=None)
| 651 | """ |
| 652 | |
| 653 | def __init__(self, parties, action=None, timeout=None): |
| 654 | """Create a barrier, initialised to 'parties' threads. |
| 655 | |
| 656 | 'action' is a callable which, when supplied, will be called by one of |
| 657 | the threads after they have all entered the barrier and just prior to |
| 658 | releasing them all. If a 'timeout' is provided, it is used as the |
| 659 | default for all subsequent 'wait()' calls. |
| 660 | |
| 661 | """ |
| 662 | self._cond = Condition(Lock()) |
| 663 | self._action = action |
| 664 | self._timeout = timeout |
| 665 | self._parties = parties |
| 666 | self._state = 0 # 0 filling, 1 draining, -1 resetting, -2 broken |
| 667 | self._count = 0 |
| 668 | |
| 669 | def __repr__(self): |
| 670 | cls = self.__class__ |