本文整理匯總了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.
示例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.
示例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)
示例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)
示例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)))
示例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)
示例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()
示例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)
示例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
示例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
示例11: _StopThread
# 需要導入模塊: import win32event [as 別名]
# 或者: from win32event import SetEvent [as 別名]
def _StopThread(self):
win32event.SetEvent(self.hStopThread)
self.hStopThread = None
示例12: _DocumentStateChanged
# 需要導入模塊: import win32event [as 別名]
# 或者: from win32event import SetEvent [as 別名]
def _DocumentStateChanged(self):
win32event.SetEvent(self.adminEvent)
示例13: SignalStop
# 需要導入模塊: import win32event [as 別名]
# 或者: from win32event import SetEvent [as 別名]
def SignalStop(self):
win32event.SetEvent(self.stopEvent)
示例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)
示例15: SvcStop
# 需要導入模塊: import win32event [as 別名]
# 或者: from win32event import SetEvent [as 別名]
def SvcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
win32event.SetEvent(self.hWaitStop)