本文整理汇总了Python中_multiprocessing.SemLock方法的典型用法代码示例。如果您正苦于以下问题:Python _multiprocessing.SemLock方法的具体用法?Python _multiprocessing.SemLock怎么用?Python _multiprocessing.SemLock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类_multiprocessing
的用法示例。
在下文中一共展示了_multiprocessing.SemLock方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import _multiprocessing [as 别名]
# 或者: from _multiprocessing import SemLock [as 别名]
def __init__(self, kind, value, maxvalue):
sl = self._semlock = _multiprocessing.SemLock(kind, value, maxvalue)
debug('created semlock with handle %s' % sl.handle)
self._make_methods()
if sys.platform != 'win32':
def _after_fork(obj):
obj._semlock._after_fork()
register_after_fork(self, _after_fork)
示例2: __setstate__
# 需要导入模块: import _multiprocessing [as 别名]
# 或者: from _multiprocessing import SemLock [as 别名]
def __setstate__(self, state):
self._semlock = _multiprocessing.SemLock._rebuild(*state)
debug('recreated blocker with handle %r' % state[0])
self._make_methods()
#
# Semaphore
#
示例3: __init__
# 需要导入模块: import _multiprocessing [as 别名]
# 或者: from _multiprocessing import SemLock [as 别名]
def __init__(self, kind, value, maxvalue, *, ctx):
if ctx is None:
ctx = context._default_context.get_context()
name = ctx.get_start_method()
unlink_now = sys.platform == 'win32' or name == 'fork'
for i in range(100):
try:
sl = self._semlock = _multiprocessing.SemLock(
kind, value, maxvalue, self._make_name(),
unlink_now)
except FileExistsError:
pass
else:
break
else:
raise FileExistsError('cannot find name for semaphore')
util.debug('created semlock with handle %s' % sl.handle)
self._make_methods()
if sys.platform != 'win32':
def _after_fork(obj):
obj._semlock._after_fork()
util.register_after_fork(self, _after_fork)
if self._semlock.name is not None:
# We only get here if we are on Unix with forking
# disabled. When the object is garbage collected or the
# process shuts down we unlink the semaphore name
from .semaphore_tracker import register
register(self._semlock.name)
util.Finalize(self, SemLock._cleanup, (self._semlock.name,),
exitpriority=0)
示例4: __setstate__
# 需要导入模块: import _multiprocessing [as 别名]
# 或者: from _multiprocessing import SemLock [as 别名]
def __setstate__(self, state):
self._semlock = _multiprocessing.SemLock._rebuild(*state)
util.debug('recreated blocker with handle %r' % state[0])
self._make_methods()
示例5: _make_name
# 需要导入模块: import _multiprocessing [as 别名]
# 或者: from _multiprocessing import SemLock [as 别名]
def _make_name():
return '%s-%s' % (process.current_process()._config['semprefix'],
next(SemLock._rand))
#
# Semaphore
#