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


Python _testcapi._test_thread_state方法代码示例

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


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

示例1: test_thread_state

# 需要导入模块: import _testcapi [as 别名]
# 或者: from _testcapi import _test_thread_state [as 别名]
def test_thread_state(self):
        # some extra thread-state tests driven via _testcapi
        def target():
            idents = []

            def callback():
                idents.append(thread.get_ident())

            _testcapi._test_thread_state(callback)
            a = b = callback
            time.sleep(1)
            # Check our main thread is in the list exactly 3 times.
            self.assertEqual(idents.count(thread.get_ident()), 3,
                             "Couldn't find main thread correctly in the list")

        target()
        t = threading.Thread(target=target)
        t.start()
        t.join() 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:21,代码来源:test_capi.py

示例2: test_thread_state

# 需要导入模块: import _testcapi [as 别名]
# 或者: from _testcapi import _test_thread_state [as 别名]
def test_thread_state(self):
        # some extra thread-state tests driven via _testcapi
        def target():
            idents = []

            def callback():
                idents.append(threading.get_ident())

            _testcapi._test_thread_state(callback)
            a = b = callback
            time.sleep(1)
            # Check our main thread is in the list exactly 3 times.
            self.assertEqual(idents.count(threading.get_ident()), 3,
                             "Couldn't find main thread correctly in the list")

        target()
        t = threading.Thread(target=target)
        t.start()
        t.join() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:21,代码来源:test_capi.py

示例3: test_main

# 需要导入模块: import _testcapi [as 别名]
# 或者: from _testcapi import _test_thread_state [as 别名]
def test_main():

    for name in dir(_testcapi):
        if name.startswith('test_'):
            test = getattr(_testcapi, name)
            if test_support.verbose:
                print "internal", name
            try:
                test()
            except _testcapi.error:
                raise test_support.TestFailed, sys.exc_info()[1]

    # some extra thread-state tests driven via _testcapi
    def TestThreadState():
        import thread
        import time

        if test_support.verbose:
            print "auto-thread-state"

        idents = []

        def callback():
            idents.append(thread.get_ident())

        _testcapi._test_thread_state(callback)
        a = b = callback
        time.sleep(1)
        # Check our main thread is in the list exactly 3 times.
        if idents.count(thread.get_ident()) != 3:
            raise test_support.TestFailed, \
                  "Couldn't find main thread correctly in the list"

    try:
        _testcapi._test_thread_state
        have_thread_state = True
    except AttributeError:
        have_thread_state = False

    if have_thread_state:
        TestThreadState()
        import threading
        t=threading.Thread(target=TestThreadState)
        t.start()
        t.join() 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:47,代码来源:test_capi.py


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