(self, n=1)
| 282 | self._lock.acquire() |
| 283 | |
| 284 | def notify(self, n=1): |
| 285 | assert self._lock._semlock._is_mine(), 'lock is not owned' |
| 286 | assert not self._wait_semaphore.acquire( |
| 287 | False), ('notify: Should not have been able to acquire ' |
| 288 | + '_wait_semaphore') |
| 289 | |
| 290 | # to take account of timeouts since last notify*() we subtract |
| 291 | # woken_count from sleeping_count and rezero woken_count |
| 292 | while self._woken_count.acquire(False): |
| 293 | res = self._sleeping_count.acquire(False) |
| 294 | assert res, ('notify: Bug in sleeping_count.acquire' |
| 295 | + '- res should not be False') |
| 296 | |
| 297 | sleepers = 0 |
| 298 | while sleepers < n and self._sleeping_count.acquire(False): |
| 299 | self._wait_semaphore.release() # wake up one sleeper |
| 300 | sleepers += 1 |
| 301 | |
| 302 | if sleepers: |
| 303 | for i in range(sleepers): |
| 304 | self._woken_count.acquire() # wait for a sleeper to wake |
| 305 | |
| 306 | # rezero wait_semaphore in case some timeouts just happened |
| 307 | while self._wait_semaphore.acquire(False): |
| 308 | pass |
| 309 | |
| 310 | def notify_all(self): |
| 311 | self.notify(n=sys.maxsize) |
no test coverage detected