本文整理匯總了Python中gevent.coros.Semaphore方法的典型用法代碼示例。如果您正苦於以下問題:Python coros.Semaphore方法的具體用法?Python coros.Semaphore怎麽用?Python coros.Semaphore使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gevent.coros
的用法示例。
在下文中一共展示了coros.Semaphore方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: allocate_lock
# 需要導入模塊: from gevent import coros [as 別名]
# 或者: from gevent.coros import Semaphore [as 別名]
def allocate_lock():
return LockType(1)
示例2: __init__
# 需要導入模塊: from gevent import coros [as 別名]
# 或者: from gevent.coros import Semaphore [as 別名]
def __init__(self, size=None, greenlet_class=None):
if size is not None and size < 1:
raise ValueError('Invalid size for pool (positive integer or None required): %r' % (size, ))
Group.__init__(self)
self.size = size
if greenlet_class is not None:
self.greenlet_class = greenlet_class
if size is None:
self._semaphore = DummySemaphore()
else:
self._semaphore = Semaphore(size)
示例3: __init__
# 需要導入模塊: from gevent import coros [as 別名]
# 或者: from gevent.coros import Semaphore [as 別名]
def __init__(self):
"""Create a :class:`SequentialGeventHandler` instance"""
self.callback_queue = Queue()
self._running = False
self._async = None
self._state_change = Semaphore()
self._workers = []
示例4: __init__
# 需要導入模塊: from gevent import coros [as 別名]
# 或者: from gevent.coros import Semaphore [as 別名]
def __init__(self):
io.RawIOBase.__init__(self)
self.buf = bytearray()
self.target_size = 0
self.semaphore = Semaphore()
self._closed = False