當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。