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


Python win32event.WaitForSingleObject方法代码示例

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


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

示例1: wait

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import WaitForSingleObject [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) 
开发者ID:cherrypy,项目名称:cherrypy,代码行数:19,代码来源:win32.py

示例2: wait

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import WaitForSingleObject [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) 
开发者ID:binhex,项目名称:moviegrabber,代码行数:18,代码来源:win32.py

示例3: __windows_start_process__

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import WaitForSingleObject [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") 
开发者ID:BYU-PCCL,项目名称:holodeck,代码行数:18,代码来源:environments.py

示例4: run

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import WaitForSingleObject [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 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:advanced.py

示例5: testNotifyChange

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import WaitForSingleObject [as 别名]
def testNotifyChange(self):
        def change():
            hkey = win32api.RegCreateKey(win32con.HKEY_CURRENT_USER, self.key_name)
            try:
                win32api.RegSetValue(hkey, None, win32con.REG_SZ, "foo")
            finally:
                win32api.RegDeleteKey(win32con.HKEY_CURRENT_USER, self.key_name)

        evt = win32event.CreateEvent(None,0,0,None)
        ## REG_NOTIFY_CHANGE_LAST_SET - values
        ## REG_CHANGE_NOTIFY_NAME - keys
        ## REG_NOTIFY_CHANGE_SECURITY - security descriptor
        ## REG_NOTIFY_CHANGE_ATTRIBUTES
        win32api.RegNotifyChangeKeyValue(win32con.HKEY_CURRENT_USER,1,win32api.REG_NOTIFY_CHANGE_LAST_SET,evt,True)
        ret_code=win32event.WaitForSingleObject(evt,0)
        # Should be no change.
        self.failUnless(ret_code==win32con.WAIT_TIMEOUT)
        change()
        # Our event should now be in a signalled state.
        ret_code=win32event.WaitForSingleObject(evt,0)
        self.failUnless(ret_code==win32con.WAIT_OBJECT_0) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:23,代码来源:test_win32api.py

示例6: closeApp

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import WaitForSingleObject [as 别名]
def closeApp(self, hProcess, title):
            """
            Close Application by window title
            """

            try:
                win32gui.EnumWindows(FileWriterLauncherGui.enumCallback, title)

                if proc is not None:
                    win32event.WaitForSingleObject(hProcess, 5 * 1000)
                    win32api.CloseHandle(hProcess)

                    for pid in self.genChildProcesses(proc):
                        try:
                            handle = win32api.OpenProcess(1, False, pid)
                            win32process.TerminateProcess(handle, -1)
                            win32api.CloseHandle(handle)
                        except:
                            pass

            except:
                pass 
开发者ID:MozillaSecurity,项目名称:peach,代码行数:24,代码来源:process.py

示例7: socket_bind_recv

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import WaitForSingleObject [as 别名]
def socket_bind_recv(socket_fn, cmd_handler):
    """
    非bsd系统的进程间通信,接受消息,处理消息,使用windows全局共享内存实现,
    函数名称保持与bsd的接口名称一致
    :param socket_fn: 共享内存文件名称
    :param cmd_handler: cmd处理函数,callable类型
    """
    if not callable(cmd_handler):
        print('socket_bind_recv cmd_handler must callable!')

    while True:
        global_fn = 'Global\\{}'.format(socket_fn)
        event = w32e.CreateEvent(None, 0, 0, global_fn)
        event_mmap = mmf.mmapfile(None, socket_fn, 1024)
        w32e.WaitForSingleObject(event, -1)
        socket_cmd = event_mmap.read(1024).decode()
        # 把接收到的socket传递给外部对应的处理函数
        cmd_handler(socket_cmd)
        event_mmap.close()
        win_api.CloseHandle(event) 
开发者ID:bbfamily,项目名称:abu,代码行数:22,代码来源:ABuWinUtil.py

示例8: Transmit

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import WaitForSingleObject [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 
开发者ID:EventGhost,项目名称:EventGhost,代码行数:18,代码来源:__init__.py

示例9: __windows_init__

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import WaitForSingleObject [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 
开发者ID:BYU-PCCL,项目名称:holodeck,代码行数:30,代码来源:holodeckclient.py

示例10: poll

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import WaitForSingleObject [as 别名]
def poll(self):
            """Check if child process has terminated.  Returns returncode
            attribute."""
            if self.returncode == None:
                if WaitForSingleObject(self._handle, 0) == WAIT_OBJECT_0:
                    self.returncode = GetExitCodeProcess(self._handle)
                    _active.remove(self)
            return self.returncode 
开发者ID:linuxscout,项目名称:mishkal,代码行数:10,代码来源:subprocess24.py

示例11: wait

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import WaitForSingleObject [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 
开发者ID:linuxscout,项目名称:mishkal,代码行数:10,代码来源:subprocess24.py

示例12: wait_for_input

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import WaitForSingleObject [as 别名]
def wait_for_input(self, timeout):
            """
            Wait until there is some input or the timeout is hit.

            :param timeout: Time to wait for input in seconds (floating point).
            """
            rc = win32event.WaitForSingleObject(self._stdin, int(timeout * 1000))
            if rc not in [0, 258]:
                raise RuntimeError(rc) 
开发者ID:peterbrittain,项目名称:asciimatics,代码行数:11,代码来源:screen.py

示例13: transmit

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import WaitForSingleObject [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 ========================================= 
开发者ID:alexsunday,项目名称:pyvpn,代码行数:13,代码来源:tun-ping-responder.py

示例14: testRecord

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import WaitForSingleObject [as 别名]
def testRecord(self):
        d = ds.DirectSoundCaptureCreate(None, None)

        sdesc = ds.DSCBUFFERDESC()
        sdesc.dwBufferBytes = 352800 # 2 seconds
        sdesc.lpwfxFormat = pywintypes.WAVEFORMATEX()
        sdesc.lpwfxFormat.wFormatTag = pywintypes.WAVE_FORMAT_PCM
        sdesc.lpwfxFormat.nChannels = 2
        sdesc.lpwfxFormat.nSamplesPerSec = 44100
        sdesc.lpwfxFormat.nAvgBytesPerSec = 176400
        sdesc.lpwfxFormat.nBlockAlign = 4
        sdesc.lpwfxFormat.wBitsPerSample = 16

        buffer = d.CreateCaptureBuffer(sdesc)

        event = win32event.CreateEvent(None, 0, 0, None)
        notify = buffer.QueryInterface(ds.IID_IDirectSoundNotify)

        notify.SetNotificationPositions((ds.DSBPN_OFFSETSTOP, event))

        buffer.Start(0)

        win32event.WaitForSingleObject(event, -1)
        event.Close()

        data = buffer.Update(0, 352800)
        fname=os.path.join(win32api.GetTempPath(), 'test_directsound_record.wav')
        f = open(fname, 'wb')
        f.write(wav_header_pack(sdesc.lpwfxFormat, 352800))
        f.write(data)
        f.close() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:33,代码来源:ds_test.py

示例15: Connect

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import WaitForSingleObject [as 别名]
def Connect(entryName, bUseCallback):
    if bUseCallback:
        theCallback = Callback
        win32event.ResetEvent(callbackEvent)
    else:
        theCallback = None
    #       in order to *use* the username/password of a particular dun entry, one must
    #       explicitly get those params under win95....
    try:
        dp, b = win32ras.GetEntryDialParams( None, entryName )
    except:
        print "Couldn't find DUN entry: %s" % entryName
    else:
        hras, rc = win32ras.Dial(None, None, (entryName, "", "", dp[ 3 ], dp[ 4 ], ""),theCallback)
    #       hras, rc = win32ras.Dial(None, None, (entryName, ),theCallback)
    #       print hras, rc
        if not bUseCallback and rc != 0:
            print "Could not dial the RAS connection:", win32ras.GetErrorString(rc)
            hras = HangUp( hras )
        #       don't wait here if there's no need to....
        elif bUseCallback and win32event.WaitForSingleObject(callbackEvent, 60000)!=win32event.WAIT_OBJECT_0:
            print "Gave up waiting for the process to complete!"
            #       sdk docs state one must explcitly hangup, even if there's an error....
            try:
                cs = win32ras.GetConnectStatus( hras )
            except:
                #       on error, attempt a hang up anyway....
                hras = HangUp( hras )
            else:
                if int( cs[ 0 ] ) == win32ras.RASCS_Disconnected:
                    hras = HangUp( hras )
    return hras, rc 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:34,代码来源:rastest.py


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