当前位置: 首页>>代码示例>>Python>>正文


Python threading._dangling方法代码示例

本文整理汇总了Python中threading._dangling方法的典型用法代码示例。如果您正苦于以下问题:Python threading._dangling方法的具体用法?Python threading._dangling怎么用?Python threading._dangling使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在threading的用法示例。


在下文中一共展示了threading._dangling方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: threading_setup

# 需要导入模块: import threading [as 别名]
# 或者: from threading import _dangling [as 别名]
def threading_setup():
    if _thread:
        return _thread._count(), threading._dangling.copy()
    else:
        return 1, () 
开发者ID:war-and-code,项目名称:jawfish,代码行数:7,代码来源:support.py

示例2: threading_cleanup

# 需要导入模块: import threading [as 别名]
# 或者: from threading import _dangling [as 别名]
def threading_cleanup(*original_values):
    if not _thread:
        return
    _MAX_COUNT = 10
    for count in range(_MAX_COUNT):
        values = _thread._count(), threading._dangling
        if values == original_values:
            break
        time.sleep(0.1)
        gc_collect()
    # XXX print a warning in case of failure? 
开发者ID:war-and-code,项目名称:jawfish,代码行数:13,代码来源:support.py

示例3: modules_cleanup

# 需要导入模块: import threading [as 别名]
# 或者: from threading import _dangling [as 别名]
def modules_cleanup(oldmodules):
    # Encoders/decoders are registered permanently within the internal
    # codec cache. If we destroy the corresponding modules their
    # globals will be set to None which will trip up the cached functions.
    encodings = [(k, v) for k, v in sys.modules.items()
                 if k.startswith('encodings.')]
    # Was:
    # sys.modules.clear()
    # Py2-compatible:
    for i in range(len(sys.modules)):
        sys.modules.pop()

    sys.modules.update(encodings)
    # XXX: This kind of problem can affect more than just encodings. In particular
    # extension modules (such as _ssl) don't cope with reloading properly.
    # Really, test modules should be cleaning out the test specific modules they
    # know they added (ala test_runpy) rather than relying on this function (as
    # test_importhooks and test_pkg do currently).
    # Implicitly imported *real* modules should be left alone (see issue 10556).
    sys.modules.update(oldmodules)

#=======================================================================
# Backported versions of threading_setup() and threading_cleanup() which don't refer
# to threading._dangling (not available on Py2.7).

# Threading support to prevent reporting refleaks when running regrtest.py -R

# NOTE: we use thread._count() rather than threading.enumerate() (or the
# moral equivalent thereof) because a threading.Thread object is still alive
# until its __bootstrap() method has returned, even after it has been
# unregistered from the threading module.
# thread._count(), on the other hand, only gets decremented *after* the
# __bootstrap() method has returned, which gives us reliable reference counts
# at the end of a test run. 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:36,代码来源:support.py

示例4: threading_cleanup

# 需要导入模块: import threading [as 别名]
# 或者: from threading import _dangling [as 别名]
def threading_cleanup(*original_values):
    if not _thread:
        return
    _MAX_COUNT = 100
    for count in range(_MAX_COUNT):
        values = _thread._count(), threading._dangling
        if values == original_values:
            break
        time.sleep(0.01)
        gc_collect()
    # XXX print a warning in case of failure? 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:13,代码来源:__init__.py


注:本文中的threading._dangling方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。