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


Python win32event.SetEvent方法代码示例

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


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

示例1: test_connect_with_payload

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import SetEvent [as 别名]
def test_connect_with_payload(self):
        giveup_event = win32event.CreateEvent(None, 0, 0, None)
        t = threading.Thread(target=self.connect_thread_runner,
                             args=(True, giveup_event))
        t.start()
        time.sleep(0.1)
        s2 = socket.socket()
        ol = pywintypes.OVERLAPPED()
        s2.bind(('0.0.0.0', 0)) # connectex requires the socket be bound beforehand
        try:
            win32file.ConnectEx(s2, self.addr, ol, str2bytes("some expected request"))
        except win32file.error, exc:
            win32event.SetEvent(giveup_event)
            if exc.winerror == 10022: # WSAEINVAL
                raise TestSkipped("ConnectEx is not available on this platform")
            raise # some error error we don't expect. 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:test_win32file.py

示例2: test_connect_without_payload

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import SetEvent [as 别名]
def test_connect_without_payload(self):
        giveup_event = win32event.CreateEvent(None, 0, 0, None)
        t = threading.Thread(target=self.connect_thread_runner,
                             args=(False, giveup_event))
        t.start()
        time.sleep(0.1)
        s2 = socket.socket()
        ol = pywintypes.OVERLAPPED()
        s2.bind(('0.0.0.0', 0)) # connectex requires the socket be bound beforehand
        try:
            win32file.ConnectEx(s2, self.addr, ol)
        except win32file.error, exc:
            win32event.SetEvent(giveup_event)
            if exc.winerror == 10022: # WSAEINVAL
                raise TestSkipped("ConnectEx is not available on this platform")
            raise # some error error we don't expect. 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:test_win32file.py

示例3: test_addEvent

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import SetEvent [as 别名]
def test_addEvent(self):
        """
        When an event which has been added to the reactor is set, the action
        associated with the event is invoked in the reactor thread.
        """
        reactorThreadID = getThreadID()
        reactor = self.buildReactor()
        event = win32event.CreateEvent(None, False, False, None)
        finished = Deferred()
        finished.addCallback(lambda ignored: reactor.stop())
        listener = Listener(finished)
        reactor.addEvent(event, listener, 'occurred')
        reactor.callWhenRunning(win32event.SetEvent, event)
        self.runReactor(reactor)
        self.assertTrue(listener.success)
        self.assertEqual(reactorThreadID, listener.logThreadID)
        self.assertEqual(reactorThreadID, listener.eventThreadID) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:19,代码来源:test_win32events.py

示例4: test_ioThreadDoesNotChange

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import SetEvent [as 别名]
def test_ioThreadDoesNotChange(self):
        """
        Using L{IReactorWin32Events.addEvent} does not change which thread is
        reported as the I/O thread.
        """
        results = []
        def check(ignored):
            results.append(isInIOThread())
            reactor.stop()
        reactor = self.buildReactor()
        event = win32event.CreateEvent(None, False, False, None)
        finished = Deferred()
        listener = Listener(finished)
        finished.addCallback(check)
        reactor.addEvent(event, listener, 'occurred')
        reactor.callWhenRunning(win32event.SetEvent, event)
        self.runReactor(reactor)
        self.assertTrue(listener.success)
        self.assertEqual([True], results) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:21,代码来源:test_win32events.py

示例5: test_disconnectedOnError

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import SetEvent [as 别名]
def test_disconnectedOnError(self):
        """
        If the event handler raises an exception, the event is removed from the
        reactor and the handler's C{connectionLost} method is called in the I/O
        thread and the exception is logged.
        """
        reactorThreadID = getThreadID()
        reactor = self.buildReactor()
        event = win32event.CreateEvent(None, False, False, None)

        result = []
        finished = Deferred()
        finished.addBoth(result.append)
        finished.addBoth(lambda ignored: reactor.stop())

        listener = Listener(finished)
        reactor.addEvent(event, listener, 'brokenOccurred')
        reactor.callWhenRunning(win32event.SetEvent, event)
        self.runReactor(reactor)

        self.assertIsInstance(result[0], Failure)
        result[0].trap(RuntimeError)

        self.assertEqual(reactorThreadID, listener.connLostThreadID)
        self.assertEqual(1, len(self.flushLoggedErrors(RuntimeError))) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:27,代码来源:test_win32events.py

示例6: test_disconnectOnReturnValue

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import SetEvent [as 别名]
def test_disconnectOnReturnValue(self):
        """
        If the event handler returns a value, the event is removed from the
        reactor and the handler's C{connectionLost} method is called in the I/O
        thread.
        """
        reactorThreadID = getThreadID()
        reactor = self.buildReactor()
        event = win32event.CreateEvent(None, False, False, None)

        result = []
        finished = Deferred()
        finished.addBoth(result.append)
        finished.addBoth(lambda ignored: reactor.stop())

        listener = Listener(finished)
        reactor.addEvent(event, listener, 'returnValueOccurred')
        reactor.callWhenRunning(win32event.SetEvent, event)
        self.runReactor(reactor)

        self.assertIsInstance(result[0], Failure)
        result[0].trap(EnvironmentError)

        self.assertEqual(reactorThreadID, listener.connLostThreadID) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:26,代码来源:test_win32events.py

示例7: send_startup_event

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import SetEvent [as 别名]
def send_startup_event():
    if sys.platform == 'win32':
        try:
            import win32event
            import win32api
        except:
            return

        try:
            if DEBUG:
                log('bg::send_startup_event')
            startupEvent = win32event.CreateEvent(None, 0, 0, 'startupEvent')
            win32event.SetEvent(startupEvent)
            win32api.CloseHandle(startupEvent)
            if DEBUG:
                log('bg::send_startup_event: done')
        except:
            log_exc() 
开发者ID:alesnav,项目名称:p2ptv-pi,代码行数:20,代码来源:BackgroundProcess.py

示例8: test_addEvent

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import SetEvent [as 别名]
def test_addEvent(self):
        """
        When an event which has been added to the reactor is set, the action
        associated with the event is invoked.
        """
        reactor = self.buildReactor()
        event = win32event.CreateEvent(None, False, False, None)
        class Listener(object):
            success = False

            def logPrefix(self):
                return 'Listener'

            def occurred(self):
                self.success = True
                reactor.stop()

        listener = Listener()
        reactor.addEvent(event, listener, 'occurred')
        reactor.callWhenRunning(win32event.SetEvent, event)
        self.runReactor(reactor)
        self.assertTrue(listener.success) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:24,代码来源:test_win32events.py

示例9: SvcStop

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import SetEvent [as 别名]
def SvcStop(self):
        self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
        win32event.SetEvent(self.hWaitStop)
        self.isAlive = False 
开发者ID:AutohomeRadar,项目名称:Windows-Agent,代码行数:6,代码来源:agent.py

示例10: JobTransferred

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import SetEvent [as 别名]
def JobTransferred(self, job):
        print 'Job Transferred', job
        job.Complete()
        win32event.SetEvent(StopEvent) # exit msg pump 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_bits.py

示例11: _StopThread

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import SetEvent [as 别名]
def _StopThread(self):
		win32event.SetEvent(self.hStopThread)
		self.hStopThread = None 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:TraceCollector.py

示例12: _DocumentStateChanged

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import SetEvent [as 别名]
def _DocumentStateChanged(self):
		win32event.SetEvent(self.adminEvent) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:4,代码来源:document.py

示例13: SignalStop

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import SetEvent [as 别名]
def SignalStop(self):
		win32event.SetEvent(self.stopEvent) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:4,代码来源:document.py

示例14: Callback

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import SetEvent [as 别名]
def Callback( hras, msg, state, error, exterror):
#       print "Callback called with ", hras, msg, state, error, exterror
    stateName = stateMap.get(state, "Unknown state?")
    print "Status is %s (%04lx), error code is %d" % (stateName, state, error)
    finished = state in [win32ras.RASCS_Connected]
    if finished:
        win32event.SetEvent(callbackEvent)
    if error != 0 or int( state ) == win32ras.RASCS_Disconnected:
        #       we know for sure this is a good place to hangup....
        print "Detected call failure: %s" % win32ras.GetErrorString( error )
        HangUp( hras )
        win32event.SetEvent(callbackEvent) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:14,代码来源:rastest.py

示例15: SvcStop

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import SetEvent [as 别名]
def SvcStop(self):
        self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
        win32event.SetEvent(self.hWaitStop) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:serviceEvents.py


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