我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用select.KQ_EV_ADD。
def register(self, fileobj, events, data=None): key = super(KqueueSelector, self).register(fileobj, events, data) if events & EVENT_READ: kevent = select.kevent(key.fd, select.KQ_FILTER_READ, select.KQ_EV_ADD) _syscall_wrapper(self._kqueue.control, False, [kevent], 0, 0) if events & EVENT_WRITE: kevent = select.kevent(key.fd, select.KQ_FILTER_WRITE, select.KQ_EV_ADD) _syscall_wrapper(self._kqueue.control, False, [kevent], 0, 0) return key
def register(self, fileobj, events, data=None): key = super(KqueueSelector, self).register(fileobj, events, data) if events & EVENT_READ: kevent = select.kevent(key.fd, select.KQ_FILTER_READ, select.KQ_EV_ADD) _syscall_wrapper(self._wrap_control, False, [kevent], 0, 0) if events & EVENT_WRITE: kevent = select.kevent(key.fd, select.KQ_FILTER_WRITE, select.KQ_EV_ADD) _syscall_wrapper(self._wrap_control, False, [kevent], 0, 0) return key
def register(self, fid, event): flags = select.KQ_EV_ADD if event & _AsyncPoller._Read: flags |= select.KQ_EV_ENABLE else: flags |= select.KQ_EV_DISABLE self.poller.control([select.kevent(fid, filter=select.KQ_FILTER_READ, flags=flags)], 0) flags = select.KQ_EV_ADD if event & _AsyncPoller._Write: flags |= select.KQ_EV_ENABLE else: flags |= select.KQ_EV_DISABLE self.poller.control([select.kevent(fid, filter=select.KQ_FILTER_WRITE, flags=flags)], 0)