Semaphores - kombu.async.semaphore¶
Semaphores and concurrency primitives.
Pretending to be a lock.
Asynchronous Bounded Semaphore.
Lax means that the value will stay within the specified range even if released more times than it was acquired.
>>> from future import print_statement as printf # ^ ignore: just fooling stupid pyflakes
>>> x = LaxBoundedSemaphore(2)
>>> x.acquire(printf, 'HELLO 1') HELLO 1
>>> x.acquire(printf, 'HELLO 2') HELLO 2
>>> x.acquire(printf, 'HELLO 3') >>> x._waiters # private, do not access directly [print, ('HELLO 3', )]
>>> x.release() HELLO 3
Acquire semaphore, applying
callbackif the resource is available.
- callback – The callback to apply.
- *partial_args – partial arguments to callback.
Reset the semaphore, which also wipes out any waiting callbacks.
Change the size of the semaphore to accept more users.
If there are any waiters this will apply the first waiter that is waiting for the resource (FIFO order).
Change the size of the semaphore to accept less users.