本文整理匯總了Python中win32event.WAIT_TIMEOUT屬性的典型用法代碼示例。如果您正苦於以下問題:Python win32event.WAIT_TIMEOUT屬性的具體用法?Python win32event.WAIT_TIMEOUT怎麽用?Python win32event.WAIT_TIMEOUT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類win32event
的用法示例。
在下文中一共展示了win32event.WAIT_TIMEOUT屬性的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __windows_start_process__
# 需要導入模塊: import win32event [as 別名]
# 或者: from win32event import WAIT_TIMEOUT [as 別名]
def __windows_start_process__(self, binary_path, task_key, verbose):
import win32event
out_stream = sys.stdout if verbose else open(os.devnull, 'w')
loading_semaphore = win32event.CreateSemaphore(None, 0, 1,
'Global\\HOLODECK_LOADING_SEM' + self._uuid)
self._world_process = \
subprocess.Popen([binary_path, task_key, '-HolodeckOn', '-LOG=HolodeckLog.txt',
'-ForceRes', '-ResX=' + str(self._window_size[1]), '-ResY=' +
str(self._window_size[0]), '-TicksPerSec=' + str(self._ticks_per_sec),
'--HolodeckUUID=' + self._uuid],
stdout=out_stream, stderr=out_stream)
atexit.register(self.__on_exit__)
response = win32event.WaitForSingleObject(loading_semaphore, 100000) # 100 second timeout
if response == win32event.WAIT_TIMEOUT:
raise HolodeckException("Timed out waiting for binary to load")
示例2: testWaitableTrigger
# 需要導入模塊: import win32event [as 別名]
# 或者: from win32event import WAIT_TIMEOUT [as 別名]
def testWaitableTrigger(self):
h = win32event.CreateWaitableTimer(None, 0, None)
# for the sake of this, pass a long that doesn't fit in an int.
dt = -2000000000
win32event.SetWaitableTimer(h, dt, 0, None, None, 0)
rc = win32event.WaitForSingleObject(h, 10) # 10 ms.
self.failUnlessEqual(rc, win32event.WAIT_TIMEOUT)
示例3: testMsgWaitForMultipleObjects
# 需要導入模塊: import win32event [as 別名]
# 或者: from win32event import WAIT_TIMEOUT [as 別名]
def testMsgWaitForMultipleObjects(self):
# this function used to segfault when called with an empty list
res = win32event.MsgWaitForMultipleObjects([], 0, 0, 0)
self.assertEquals(res, win32event.WAIT_TIMEOUT)
示例4: testMsgWaitForMultipleObjects2
# 需要導入模塊: import win32event [as 別名]
# 或者: from win32event import WAIT_TIMEOUT [as 別名]
def testMsgWaitForMultipleObjects2(self):
# test with non-empty list
event = win32event.CreateEvent(None, 0, 0, None)
res = win32event.MsgWaitForMultipleObjects([event], 0, 0, 0)
self.assertEquals(res, win32event.WAIT_TIMEOUT)
示例5: testMsgWaitForMultipleObjectsEx
# 需要導入模塊: import win32event [as 別名]
# 或者: from win32event import WAIT_TIMEOUT [as 別名]
def testMsgWaitForMultipleObjectsEx(self):
# this function used to segfault when called with an empty list
res = win32event.MsgWaitForMultipleObjectsEx([], 0, 0, 0)
self.assertEquals(res, win32event.WAIT_TIMEOUT)
示例6: testMsgWaitForMultipleObjectsEx2
# 需要導入模塊: import win32event [as 別名]
# 或者: from win32event import WAIT_TIMEOUT [as 別名]
def testMsgWaitForMultipleObjectsEx2(self):
# test with non-empty list
event = win32event.CreateEvent(None, 0, 0, None)
res = win32event.MsgWaitForMultipleObjectsEx([event], 0, 0, 0)
self.assertEquals(res, win32event.WAIT_TIMEOUT)
示例7: connect_thread_runner
# 需要導入模塊: import win32event [as 別名]
# 或者: from win32event import WAIT_TIMEOUT [as 別名]
def connect_thread_runner(self, expect_payload, giveup_event):
# As Windows 2000 doesn't do ConnectEx, we need to use a non-blocking
# accept, as our test connection may never come. May as well use
# AcceptEx for this...
listener = socket.socket()
self.addr = ('localhost', random.randint(10000,64000))
listener.bind(self.addr)
listener.listen(1)
# create accept socket
accepter = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# An overlapped
overlapped = pywintypes.OVERLAPPED()
overlapped.hEvent = win32event.CreateEvent(None, 0, 0, None)
# accept the connection.
if expect_payload:
buf_size = 1024
else:
# when we don't expect data we must be careful to only pass the
# exact number of bytes for the endpoint data...
buf_size = win32file.CalculateSocketEndPointSize(listener)
buffer = win32file.AllocateReadBuffer(buf_size)
win32file.AcceptEx(listener, accepter, buffer, overlapped)
# wait for the connection or our test to fail.
events = giveup_event, overlapped.hEvent
rc = win32event.WaitForMultipleObjects(events, False, 2000)
if rc == win32event.WAIT_TIMEOUT:
self.fail("timed out waiting for a connection")
if rc == win32event.WAIT_OBJECT_0:
# Our main thread running the test failed and will never connect.
return
# must be a connection.
nbytes = win32file.GetOverlappedResult(listener.fileno(), overlapped, False)
if expect_payload:
self.request = buffer[:nbytes]
accepter.send(str2bytes('some expected response'))
示例8: is_modified
# 需要導入模塊: import win32event [as 別名]
# 或者: from win32event import WAIT_TIMEOUT [as 別名]
def is_modified(self, buffer):
print "path", self.path
result = win32file.ReadDirectoryChangesW(
self.handle,
buffer,
True,
win32con.FILE_NOTIFY_CHANGE_FILE_NAME
| win32con.FILE_NOTIFY_CHANGE_DIR_NAME
| win32con.FILE_NOTIFY_CHANGE_ATTRIBUTES
| win32con.FILE_NOTIFY_CHANGE_SIZE
| win32con.FILE_NOTIFY_CHANGE_LAST_WRITE
| win32con.FILE_NOTIFY_CHANGE_SECURITY,
self.overlapped,
)
print "result 1", result
result = win32event.WaitForMultipleObjects([self.overlapped.hEvent], True, 0)
print "result 2", result
if result != win32event.WAIT_TIMEOUT:
# result = win32file.GetOverlappedResult(self.handle, self.overlapped, False)
return True
else:
return False
#===========================================================================
# Directory monitor class.
示例9: doWaitForMultipleEvents
# 需要導入模塊: import win32event [as 別名]
# 或者: from win32event import WAIT_TIMEOUT [as 別名]
def doWaitForMultipleEvents(self, timeout):
log.msg(channel='system', event='iteration', reactor=self)
if timeout is None:
#timeout = INFINITE
timeout = 100
else:
timeout = int(timeout * 1000)
if not (self._events or self._writes):
# sleep so we don't suck up CPU time
time.sleep(timeout / 1000.0)
return
canDoMoreWrites = 0
for fd in self._writes.keys():
if log.callWithLogger(fd, self._runWrite, fd):
canDoMoreWrites = 1
if canDoMoreWrites:
timeout = 0
handles = self._events.keys() or [self.dummyEvent]
val = MsgWaitForMultipleObjects(handles, 0, timeout, QS_ALLINPUT | QS_ALLEVENTS)
if val == WAIT_TIMEOUT:
return
elif val == WAIT_OBJECT_0 + len(handles):
exit = win32gui.PumpWaitingMessages()
if exit:
self.callLater(0, self.stop)
return
elif val >= WAIT_OBJECT_0 and val < WAIT_OBJECT_0 + len(handles):
fd, action = self._events[handles[val - WAIT_OBJECT_0]]
log.callWithLogger(fd, self._runAction, action, fd)
示例10: Write
# 需要導入模塊: import win32event [as 別名]
# 或者: from win32event import WAIT_TIMEOUT [as 別名]
def Write(self, data, timeout):
if self.handle:
try:
self.lockObject.acquire()
if eg.debugLevel:
print "writing " + str(len(data)) + " bytes to " + self.getName()
if not self._overlappedWrite:
self._overlappedWrite = win32file.OVERLAPPED()
err, n = win32file.WriteFile(self.handle, data, self._overlappedWrite)
if err: #will be ERROR_IO_PENDING:
# Wait for the write to complete.
n = win32file.GetOverlappedResult(self.handle, self._overlappedWrite, 1)
if n != len(data):
raise Exception("could not write full data")
elif n != len(data):
raise Exception("could not write full data")
if timeout: #waits for response from device
win32event.ResetEvent(self._overlappedRead.hEvent)
res = win32event.WaitForSingleObject(self._overlappedRead.hEvent, timeout)
if res == win32event.WAIT_TIMEOUT:
raise Exception("no response from device within timeout")
finally:
self.lockObject.release()
else:
raise Exception("invalid handle")
return