MCPcopy Index your code
hub / github.com/python/cpython / notify

Method notify

Lib/multiprocessing/synchronize.py:284–308  ·  view source on GitHub ↗
(self, n=1)

Source from the content-addressed store, hash-verified

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)

Callers 7

notify_allMethod · 0.95
putMethod · 0.45
_finalize_closeMethod · 0.45
putMethod · 0.45
_setMethod · 0.45
_set_lengthMethod · 0.45
_setMethod · 0.45

Calls 2

acquireMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected