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


Python thread.start_new方法代码示例

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


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

示例1: intercept_threads

# 需要导入模块: import thread [as 别名]
# 或者: from thread import start_new [as 别名]
def intercept_threads(for_attach = False):
    thread.start_new_thread = thread_creator
    thread.start_new = thread_creator

    # If threading has already been imported (i.e. we're attaching), we must hot-patch threading._start_new_thread
    # so that new threads started using it will be intercepted by our code.
    #
    # On the other hand, if threading has not been imported, we must not import it ourselves, because it will then
    # treat the current thread as the main thread, which is incorrect when attaching because this code is executing
    # on an ephemeral debugger attach thread that will go away shortly. We don't need to hot-patch it in that case
    # anyway, because it will pick up the new thread.start_new_thread that we have set above when it's imported.
    global _threading
    if _threading is None and 'threading' in sys.modules:
        import threading
        _threading = threading
        _threading._start_new_thread = thread_creator

    global _INTERCEPTING_FOR_ATTACH
    _INTERCEPTING_FOR_ATTACH = for_attach 
开发者ID:ms-iot,项目名称:iot-utilities,代码行数:21,代码来源:visualstudio_py_debugger.py

示例2: __init__

# 需要导入模块: import thread [as 别名]
# 或者: from thread import start_new [as 别名]
def __init__(self, *args):
		winout.WindowOutput.__init__(*(self,)+args)
		self.hStopThread = win32event.CreateEvent(None, 0, 0, None)
		thread.start_new(CollectorThread, (self.hStopThread, self)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:TraceCollector.py

示例3: startPycheckerRun

# 需要导入模块: import thread [as 别名]
# 或者: from thread import start_new [as 别名]
def startPycheckerRun(self):
        self.result=None
        old=win32api.SetCursor(win32api.LoadCursor(0, win32con.IDC_APPSTARTING))
        win32ui.GetApp().AddIdleHandler(self.idleHandler)
        import thread
        thread.start_new(self.threadPycheckerRun,())
        ##win32api.SetCursor(old) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:mdi_pychecker.py

示例4: BeginThreadsSimpleMarshal

# 需要导入模块: import thread [as 别名]
# 或者: from thread import start_new [as 别名]
def BeginThreadsSimpleMarshal(numThreads, cookie):
    """Creates multiple threads using simple (but slower) marshalling.
    
    Single interpreter object, but a new stream is created per thread.
    
    Returns the handles the threads will set when complete.
    """
    ret = []
    for i in range(numThreads):
        hEvent = win32event.CreateEvent(None, 0, 0, None)
        thread.start_new(TestInterpInThread, (hEvent, cookie))
        ret.append(hEvent)
    return ret 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:15,代码来源:testGIT.py

示例5: test_start_new

# 需要导入模块: import thread [as 别名]
# 或者: from thread import start_new [as 别名]
def test_start_new(self):
        #--Sanity
        global CALLED
        CALLED = False
        
        def tempFunc():
            global CALLED
            CALLED = 3.14
        
        thread.start_new(tempFunc, ())
        while CALLED==False:
            print ".",
            time.sleep(0.1)
        self.assertEqual(CALLED, 3.14)
        CALLED = False 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:17,代码来源:test_thread.py

示例6: detach_process

# 需要导入模块: import thread [as 别名]
# 或者: from thread import start_new [as 别名]
def detach_process():
    global DETACHED
    DETACHED = True
    if not _INTERCEPTING_FOR_ATTACH:
        if isinstance(sys.stdout, _DebuggerOutput): 
            sys.stdout = sys.stdout.old_out
        if isinstance(sys.stderr, _DebuggerOutput):
            sys.stderr = sys.stderr.old_out

    if not _INTERCEPTING_FOR_ATTACH:
        thread.start_new_thread = _start_new_thread
        thread.start_new = _start_new_thread 
开发者ID:ms-iot,项目名称:iot-utilities,代码行数:14,代码来源:visualstudio_py_debugger.py

示例7: test_wait

# 需要导入模块: import thread [as 别名]
# 或者: from thread import start_new [as 别名]
def test_wait(self):
        for i in range(NUM_THREADS):
            thread.start_new(self.f, (i,))

        time.sleep(LONGSLEEP)

        a = self.alive.keys()
        a.sort()
        self.assertEquals(a, range(NUM_THREADS))

        prefork_lives = self.alive.copy()

        if sys.platform in ['unixware7']:
            cpid = os.fork1()
        else:
            cpid = os.fork()

        if cpid == 0:
            # Child
            time.sleep(LONGSLEEP)
            n = 0
            for key in self.alive:
                if self.alive[key] != prefork_lives[key]:
                    n += 1
            os._exit(n)
        else:
            # Parent
            self.wait_impl(cpid)
            # Tell threads to die
            self.stop = 1
            time.sleep(2*SHORTSLEEP) # Wait for threads to die 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:33,代码来源:fork_wait.py


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