def inputhook_mac(): fh = FHSingleton() # stop_cb is used to cleanly terminate loop when last figure window is # closed. stop_cb = _threading_.Event() def inputhook_cb(stop): if stop_cb.is_set() or stdin_ready(): os.write(fh.wh, b'x') stop.set() t = Timer(callback=inputhook_cb) t.start() NSApp = _NSApp() _stop_on_read(fh.rh) msg(NSApp, n('run')) if not _triggered.is_set(): # app closed without firing callback, # probably due to last window being closed. # Run the loop manually in this case, # since there may be events still to process (#9734) CoreFoundation.CFRunLoopRun() stop_cb.set() t.join()
def __init__(self, py_db): PyDBDaemonThread.__init__(self, py_db) self._event = threading.Event() self._handles = [] # We could probably do things valid without this lock so that it's possible to add # handles while processing, but the implementation would also be harder to follow, # so, for now, we're either processing or adding handles, not both at the same time. self._lock = threading.Lock()
def __init__(self, server_address, RequestHandlerClass): """Constructor. May be extended, do not override.""" self.server_address = server_address self.RequestHandlerClass = RequestHandlerClass self.__is_shut_down = threading.Event() # @UndefinedVariable self.__shutdown_request = False
def __init__(self, frame_accessor, seq, var_objects): PyDBDaemonThread.__init__(self) self.frame_accessor = frame_accessor self.seq = seq self.var_objs = var_objects self.cancel_event = threading.Event()
def __init__(self, callback=None, interval=0.1): super().__init__() self.callback = callback self.interval = interval self._stopev = _threading_.Event()
n('otherEventWithType:location:modifierFlags:' 'timestamp:windowNumber:context:subtype:data1:data2:'), 15, # Type 0, # location 0, # flags 0, # timestamp 0, # window None, # context 0, # subtype 0, # data1 0, # data2 ) msg(NSApp, n('postEvent:atStart:'), void_p(event), True) _triggered = _threading_.Event() def _input_callback(fdref, flags, info): """Callback to fire when there's input to be read""" _triggered.set() CFFileDescriptorInvalidate(fdref) CFRelease(fdref) NSApp = _NSApp() msg(NSApp, n('stop:'), NSApp) _wake(NSApp) _c_callback_func_type = ctypes.CFUNCTYPE(None, void_p, void_p, void_p) _c_input_callback = _c_callback_func_type(_input_callback)