This document is for Kombu's development version, which can be significantly different from previous releases. Get the stable docs here: 5.0.
信号量- kombu.asynchronous.semaphore
¶
信号量和并发原语。
- class kombu.asynchronous.semaphore.LaxBoundedSemaphore(value: int)[源代码]¶
异步有界信号量。
Lax意味着,即使释放的次数比获取的次数多,该值也将保持在指定的范围内。
示例:¶
>>> x = LaxBoundedSemaphore(2)
>>> x.acquire(print, 'HELLO 1') HELLO 1
>>> x.acquire(print, 'HELLO 2') HELLO 2
>>> x.acquire(print, 'HELLO 3') >>> x._waiters # private, do not access directly [print, ('HELLO 3',)]
>>> x.release() HELLO 3