Semaphores - kombu.async.semaphore¶
kombu.async.semaphore¶
Semaphores and concurrency primitives.
-
class
kombu.async.semaphore.
LaxBoundedSemaphore
(value)[source]¶ Asynchronous Bounded Semaphore.
Lax means that the value will stay within the specified range even if released more times than it was acquired.
Example:
>>> 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
(callback, *partial_args)[source]¶ Acquire semaphore, applying
callback
if the resource is available.Parameters: - callback – The callback to apply.
- *partial_args – partial arguments to callback.
-