Release a lock. When the lock is locked, reset it to unlocked, and return. If any other tasks are blocked waiting for the lock to become unlocked, allow exactly one of them to proceed. When invoked on an unlocked lock, a RuntimeError is raised. There is no
(self)
| 125 | return True |
| 126 | |
| 127 | def release(self): |
| 128 | """Release a lock. |
| 129 | |
| 130 | When the lock is locked, reset it to unlocked, and return. |
| 131 | If any other tasks are blocked waiting for the lock to become |
| 132 | unlocked, allow exactly one of them to proceed. |
| 133 | |
| 134 | When invoked on an unlocked lock, a RuntimeError is raised. |
| 135 | |
| 136 | There is no return value. |
| 137 | """ |
| 138 | if self._locked: |
| 139 | self._locked = False |
| 140 | self._wake_up_first() |
| 141 | else: |
| 142 | raise RuntimeError('Lock is not acquired.') |
| 143 | |
| 144 | def _wake_up_first(self): |
| 145 | """Ensure that the first waiter will wake up.""" |