本文整理汇总了Python中win32event.INFINITE属性的典型用法代码示例。如果您正苦于以下问题:Python win32event.INFINITE属性的具体用法?Python win32event.INFINITE怎么用?Python win32event.INFINITE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类win32event
的用法示例。
在下文中一共展示了win32event.INFINITE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wait
# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import INFINITE [as 别名]
def wait(self, state, interval=0.1, channel=None):
"""Wait for the given state(s), KeyboardInterrupt or SystemExit.
Since this class uses native win32event objects, the interval
argument is ignored.
"""
if isinstance(state, (tuple, list)):
# Don't wait for an event that beat us to the punch ;)
if self.state not in state:
events = tuple([self._get_state_event(s) for s in state])
win32event.WaitForMultipleObjects(
events, 0, win32event.INFINITE)
else:
# Don't wait for an event that beat us to the punch ;)
if self.state != state:
event = self._get_state_event(state)
win32event.WaitForSingleObject(event, win32event.INFINITE)
示例2: run
# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import INFINITE [as 别名]
def run(self):
last_time = os.stat(self.filename)[stat.ST_MTIME]
while 1:
try:
rc = win32event.WaitForSingleObject(self.handle,
win32event.INFINITE)
win32file.FindNextChangeNotification(self.handle)
except win32event.error, details:
# handle closed - thread should terminate.
if details[0] != winerror.ERROR_INVALID_HANDLE:
raise
break
this_time = os.stat(self.filename)[stat.ST_MTIME]
if this_time != last_time:
print "Detected file change - flagging for reload."
self.change_detected = True
last_time = this_time
示例3: CollectorThread
# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import INFINITE [as 别名]
def CollectorThread(stopEvent, file):
win32trace.InitRead()
handle = win32trace.GetHandle()
# Run this thread at a lower priority to the main message-loop (and printing output)
# thread can keep up
import win32process
win32process.SetThreadPriority(win32api.GetCurrentThread(), win32process.THREAD_PRIORITY_BELOW_NORMAL)
try:
while 1:
rc = win32event.WaitForMultipleObjects((handle, stopEvent), 0, win32event.INFINITE)
if rc == win32event.WAIT_OBJECT_0:
# About the only char we can't live with is \0!
file.write(win32trace.read().replace("\0", "<null>"))
else:
# Stop event
break
finally:
win32trace.TermRead()
print "Thread dieing"
示例4: Run
# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import INFINITE [as 别名]
def Run(self):
while 1:
handles = [self.stopEvent, self.adminEvent]
if self.watchEvent is not None:
handles.append(self.watchEvent)
rc = win32event.WaitForMultipleObjects(handles, 0, win32event.INFINITE)
if rc == win32event.WAIT_OBJECT_0:
break
elif rc == win32event.WAIT_OBJECT_0+1:
self.RefreshEvent()
else:
win32api.PostMessage(self.hwnd, MSG_CHECK_EXTERNAL_FILE, 0, 0)
try:
# If the directory has been removed underneath us, we get this error.
win32api.FindNextChangeNotification(self.watchEvent)
except win32api.error, exc:
print "Can not watch file", self.doc.GetPathName(), "for changes -", exc.strerror
break
# close a circular reference
示例5: wait
# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import INFINITE [as 别名]
def wait(self, state, interval=0.1, channel=None):
"""Wait for the given state(s), KeyboardInterrupt or SystemExit.
Since this class uses native win32event objects, the interval
argument is ignored.
"""
if isinstance(state, (tuple, list)):
# Don't wait for an event that beat us to the punch ;)
if self.state not in state:
events = tuple([self._get_state_event(s) for s in state])
win32event.WaitForMultipleObjects(events, 0, win32event.INFINITE)
else:
# Don't wait for an event that beat us to the punch ;)
if self.state != state:
event = self._get_state_event(state)
win32event.WaitForSingleObject(event, win32event.INFINITE)
示例6: Transmit
# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import INFINITE [as 别名]
def Transmit(self, transmitData):
"""
This will be called to detect available IR Blasters.
"""
if not self.file:
if not self.connecting:
self.Connect()
else:
return False
while self.receiving:
time.sleep(0.05)
writeOvlap = win32file.OVERLAPPED()
writeOvlap.hEvent = win32event.CreateEvent(None, 0, 0, None)
win32file.WriteFile(self.file, transmitData, writeOvlap)
win32event.WaitForSingleObject(writeOvlap.hEvent, win32event.INFINITE)
return True
示例7: __windows_init__
# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import INFINITE [as 别名]
def __windows_init__(self):
import win32event
semaphore_all_access = 0x1F0003
self.timeout = 5000 if self.should_timeout else win32event.INFINITE
self._semaphore1 = \
win32event.OpenSemaphore(semaphore_all_access, False,
"Global\\HOLODECK_SEMAPHORE_SERVER" + self._uuid)
self._semaphore2 = \
win32event.OpenSemaphore(semaphore_all_access, False,
"Global\\HOLODECK_SEMAPHORE_CLIENT" + self._uuid)
def windows_acquire_semaphore(sem):
result = win32event.WaitForSingleObject(sem, self.timeout)
if result != win32event.WAIT_OBJECT_0:
raise TimeoutError("Timed out or error waiting for engine!")
def windows_release_semaphore(sem):
win32event.ReleaseSemaphore(sem, 1)
def windows_unlink():
pass
self._get_semaphore_fn = windows_acquire_semaphore
self._release_semaphore_fn = windows_release_semaphore
self.unlink = windows_unlink
示例8: wait
# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import INFINITE [as 别名]
def wait(self):
"""Wait for child process to terminate. Returns returncode
attribute."""
if self.returncode == None:
obj = WaitForSingleObject(self._handle, INFINITE)
self.returncode = GetExitCodeProcess(self._handle)
_active.remove(self)
return self.returncode
示例9: transmit
# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import INFINITE [as 别名]
def transmit(self,dataToTransmit):
# convert to string
dataToTransmit = ''.join([chr(b) for b in dataToTransmit])
# write over tuntap interface
win32file.WriteFile(self.tuntap, dataToTransmit, self.overlappedTx)
win32event.WaitForSingleObject(self.overlappedTx.hEvent, win32event.INFINITE)
self.overlappedTx.Offset = self.overlappedTx.Offset + len(dataToTransmit)
#======================== private =========================================
示例10: run
# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import INFINITE [as 别名]
def run(self):
self.running = True
while self.running:
errCode, bytes, key, overlapped = \
GetQueuedCompletionStatus(self.io_req_port, INFINITE)
if key == ISAPI_SHUTDOWN and overlapped is None:
break
# Let the parent extension handle the command.
dispatcher = self.extension.dispatch_map.get(key)
if dispatcher is None:
raise RuntimeError("Bad request '%s'" % (key,))
dispatcher(errCode, bytes, key, overlapped)
示例11: SvcDoRun
# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import INFINITE [as 别名]
def SvcDoRun(self):
# do nothing at all - just wait to be stopped
win32event.WaitForSingleObject(self.hWaitStop, win32event.INFINITE)
# Write a stop message.
servicemanager.LogMsg(
servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STOPPED,
(self._svc_name_, '')
)
示例12: join
# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import INFINITE [as 别名]
def join(self):
win32event.WaitForSingleObject(self.processHandle,
win32event.INFINITE)
self.exitCode = win32process.GetExitCodeProcess(self.processHandle)
示例13: testSimpleOverlapped
# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import INFINITE [as 别名]
def testSimpleOverlapped(self):
# Create a file in the %TEMP% directory.
import win32event
testName = os.path.join( win32api.GetTempPath(), "win32filetest.dat" )
desiredAccess = win32file.GENERIC_WRITE
overlapped = pywintypes.OVERLAPPED()
evt = win32event.CreateEvent(None, 0, 0, None)
overlapped.hEvent = evt
# Create the file and write shit-loads of data to it.
h = win32file.CreateFile( testName, desiredAccess, 0, None, win32file.CREATE_ALWAYS, 0, 0)
chunk_data = str2bytes("z") * 0x8000
num_loops = 512
expected_size = num_loops * len(chunk_data)
for i in range(num_loops):
win32file.WriteFile(h, chunk_data, overlapped)
win32event.WaitForSingleObject(overlapped.hEvent, win32event.INFINITE)
overlapped.Offset = overlapped.Offset + len(chunk_data)
h.Close()
# Now read the data back overlapped
overlapped = pywintypes.OVERLAPPED()
evt = win32event.CreateEvent(None, 0, 0, None)
overlapped.hEvent = evt
desiredAccess = win32file.GENERIC_READ
h = win32file.CreateFile( testName, desiredAccess, 0, None, win32file.OPEN_EXISTING, 0, 0)
buffer = win32file.AllocateReadBuffer(0xFFFF)
while 1:
try:
hr, data = win32file.ReadFile(h, buffer, overlapped)
win32event.WaitForSingleObject(overlapped.hEvent, win32event.INFINITE)
overlapped.Offset = overlapped.Offset + len(data)
if not data is buffer:
self.fail("Unexpected result from ReadFile - should be the same buffer we passed it")
except win32api.error:
break
h.Close()
示例14: testCompletionPortsQueued
# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import INFINITE [as 别名]
def testCompletionPortsQueued(self):
class Foo: pass
io_req_port = win32file.CreateIoCompletionPort(-1, None, 0, 0)
overlapped = pywintypes.OVERLAPPED()
overlapped.object = Foo()
win32file.PostQueuedCompletionStatus(io_req_port, 0, 99, overlapped)
errCode, bytes, key, overlapped = \
win32file.GetQueuedCompletionStatus(io_req_port, win32event.INFINITE)
self.failUnlessEqual(errCode, 0)
self.failUnless(isinstance(overlapped.object, Foo))
示例15: wait
# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import INFINITE [as 别名]
def wait(self):
"""Wait for child process to terminate. Returns returncode
attribute."""
if self.returncode is None:
obj = WaitForSingleObject(self._handle, INFINITE)
self.returncode = GetExitCodeProcess(self._handle)
return self.returncode