本文整理汇总了Python中os.register_at_fork方法的典型用法代码示例。如果您正苦于以下问题:Python os.register_at_fork方法的具体用法?Python os.register_at_fork怎么用?Python os.register_at_fork使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类os
的用法示例。
在下文中一共展示了os.register_at_fork方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import os [as 别名]
# 或者: from os import register_at_fork [as 别名]
def __init__(self):
self.reset_state()
# only available on Unix after Python 3.7
if hasattr(os, 'register_at_fork'):
os.register_at_fork(
after_in_child=lambda: _reset_augmentor_after_fork(weakref.ref(self)))
示例2: _register_at_fork_acquire_release
# 需要导入模块: import os [as 别名]
# 或者: from os import register_at_fork [as 别名]
def _register_at_fork_acquire_release(instance):
pass # no-op when os.register_at_fork does not exist.
示例3: _register_at_fork_reinit_lock
# 需要导入模块: import os [as 别名]
# 或者: from os import register_at_fork [as 别名]
def _register_at_fork_reinit_lock(instance):
pass # no-op when os.register_at_fork does not exist.
示例4: _after_at_fork_child_reinit_locks
# 需要导入模块: import os [as 别名]
# 或者: from os import register_at_fork [as 别名]
def _after_at_fork_child_reinit_locks():
# _acquireLock() was called in the parent before forking.
for handler in _at_fork_reinit_lock_weakset:
try:
handler.createLock()
except Exception as err:
# Similar to what PyErr_WriteUnraisable does.
print("Ignoring exception from logging atfork", instance,
"._reinit_lock() method:", err, file=sys.stderr)
_releaseLock() # Acquired by os.register_at_fork(before=.
示例5: mock_register_at_fork
# 需要导入模块: import os [as 别名]
# 或者: from os import register_at_fork [as 别名]
def mock_register_at_fork(func):
# bpo-30599: Mock os.register_at_fork() when importing the random module,
# since this function doesn't allow to unregister callbacks and would leak
# memory.
return mock.patch('os.register_at_fork', create=True)(func)
# Create a circular import structure: A -> C -> B -> D -> A
# NOTE: `time` is already loaded and therefore doesn't threaten to deadlock.