def cage_thread_proc(): try: pmnc.startup.start() try: while not pmnc.startup.wait(3.0): pmnc.startup.maintenance() except: pmnc.log.error(exc_string()) # log and ignore finally: pmnc.startup.stop() finally: if win32_com: # release the main thread blocked in PumpMessages PostThreadMessage(_main_thread_id, WM_QUIT)
def interruptWaitEvents(self): """ Basically a python implementation of NativeEventQueue::postEvent(). The magic value must be in sync with the C++ implementation or this won't work. Note that because of this method we cannot easily make use of a non-visible Window to handle the message like we would like to do. """ from win32api import PostThreadMessage from win32con import WM_USER self.oIntCv.acquire() self.fInterrupted = True self.oIntCv.release() try: PostThreadMessage(self.tid, WM_USER, None, 0xf241b819) except: return False return True