コード例 #1
0
 def call_soon_threadsafe(self, callback, *args):
     handler = events.make_handle(callback, args)
     # We don't use _add_callback here because starting the Idle handle
     # is not threadsafe. Instead, we queue the callback and in the Async
     # handle callback (which is run in the loop thread) we start the
     # Idle handle if needed
     self._ready.append(handler)
     self._waker.send()
     return handler
コード例 #2
0
 def add_writer(self, fd, callback, *args):
     handler = events.make_handle(callback, args)
     try:
         poll_h = self._fd_map[fd]
     except KeyError:
         poll_h = self._create_poll_handle(fd)
         self._fd_map[fd] = poll_h
     poll_h.pevents |= pyuv.UV_WRITABLE
     poll_h.write_handler = handler
     poll_h.start(poll_h.pevents, self._poll_cb)
コード例 #3
0
 def add_signal_handler(self, sig, callback, *args):
     self._validate_signal(sig)
     signal_h = pyuv.Signal(self._loop)
     handler = events.make_handle(callback, args)
     signal_h.handler = handler
     try:
         signal_h.start(self._signal_cb, sig)
     except Exception as e:
         signal_h.close()
         raise RuntimeError(str(e))
     else:
         self._signal_handlers[sig] = signal_h
     return handler
コード例 #4
0
 def call_soon(self, callback, *args):
     handler = events.make_handle(callback, args)
     self._add_callback(handler)
     return handler