Python select.KQ_EV_ENABLE Examples
The following are 17
code examples of select.KQ_EV_ENABLE().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
select
, or try the search function
.
Example #1
Source File: test_kqueue.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_issue30058(self): # changelist must be an iterable kq = select.kqueue() a, b = socket.socketpair() ev = select.kevent(a, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE) kq.control([ev], 0) # not a list kq.control((ev,), 0) # __len__ is not consistent with __iter__ class BadList: def __len__(self): return 0 def __iter__(self): for i in range(100): yield ev kq.control(BadList(), 0) # doesn't have __len__ kq.control(iter([ev]), 0) a.close() b.close() kq.close()
Example #2
Source File: test_kqueue.py From android_universal with MIT License | 6 votes |
def test_issue30058(self): # changelist must be an iterable kq = select.kqueue() a, b = socket.socketpair() ev = select.kevent(a, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE) kq.control([ev], 0) # not a list kq.control((ev,), 0) # __len__ is not consistent with __iter__ class BadList: def __len__(self): return 0 def __iter__(self): for i in range(100): yield ev kq.control(BadList(), 0) # doesn't have __len__ kq.control(iter([ev]), 0) a.close() b.close() kq.close()
Example #3
Source File: recipe-577662.py From code with MIT License | 6 votes |
def modifyRegistrationForEvents(self, asyncSocket, readEvents, writeEvents): fileno = asyncSocket.fileno() if readEvents: readKE = select.kevent(ident = fileno, filter = select.KQ_FILTER_READ, flags = select.KQ_EV_ENABLE) else: readKE = select.kevent(ident = fileno, filter = select.KQ_FILTER_READ, flags = select.KQ_EV_DISABLE) if writeEvents: writeKE = select.kevent(ident = fileno, filter = select.KQ_FILTER_WRITE, flags = select.KQ_EV_ENABLE) else: writeKE = select.kevent(ident = fileno, filter = select.KQ_FILTER_WRITE, flags = select.KQ_EV_DISABLE) # Should be able to put readKE and writeKE in a list in # one call to kqueue.control, but this is broken due to Python issue 5910 self.__kqueue.control([readKE], 0, 0) self.__kqueue.control([writeKE], 0, 0)
Example #4
Source File: poll.py From rb with Apache License 2.0 | 5 votes |
def _is_closed_kqueue(f): kqueue = select.kqueue() event = select.kevent( f.fileno(), filter=select.KQ_FILTER_READ, flags=select.KQ_EV_ADD | select.KQ_EV_ENABLE) for event in kqueue.control([event], 128, 0.0): if event.flags & select.KQ_EV_EOF: return True return False
Example #5
Source File: test_kqueue.py From BinderFilter with MIT License | 5 votes |
def testPair(self): kq = select.kqueue() a, b = socket.socketpair() a.send(b'foo') event1 = select.kevent(a, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE) event2 = select.kevent(b, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE) r = kq.control([event1, event2], 1, 1) self.assertTrue(r) self.assertFalse(r[0].flags & select.KQ_EV_ERROR) self.assertEqual(b.recv(r[0].data), b'foo') a.close() b.close() kq.close()
Example #6
Source File: test_kqueue.py From oss-ftp with MIT License | 5 votes |
def testPair(self): kq = select.kqueue() a, b = socket.socketpair() a.send(b'foo') event1 = select.kevent(a, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE) event2 = select.kevent(b, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE) r = kq.control([event1, event2], 1, 1) self.assertTrue(r) self.assertFalse(r[0].flags & select.KQ_EV_ERROR) self.assertEqual(b.recv(r[0].data), b'foo') a.close() b.close() kq.close()
Example #7
Source File: test_kqueue.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def testPair(self): kq = select.kqueue() a, b = socket.socketpair() a.send(b'foo') event1 = select.kevent(a, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE) event2 = select.kevent(b, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE) r = kq.control([event1, event2], 1, 1) self.assertTrue(r) self.assertFalse(r[0].flags & select.KQ_EV_ERROR) self.assertEqual(b.recv(r[0].data), b'foo') a.close() b.close() kq.close()
Example #8
Source File: test_kqueue.py From ironpython3 with Apache License 2.0 | 5 votes |
def testPair(self): kq = select.kqueue() a, b = socket.socketpair() a.send(b'foo') event1 = select.kevent(a, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE) event2 = select.kevent(b, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE) r = kq.control([event1, event2], 1, 1) self.assertTrue(r) self.assertFalse(r[0].flags & select.KQ_EV_ERROR) self.assertEqual(b.recv(r[0].data), b'foo') a.close() b.close() kq.close()
Example #9
Source File: poll.py From rb with Apache License 2.0 | 5 votes |
def register(self, key, f): BasePoller.register(self, key, f) r_event = select.kevent( f.fileno(), filter=select.KQ_FILTER_READ, flags=select.KQ_EV_ADD | select.KQ_EV_ENABLE) self.events.append(r_event) w_event = select.kevent( f.fileno(), filter=select.KQ_FILTER_WRITE, flags=select.KQ_EV_ADD | select.KQ_EV_ENABLE) self.events.append(w_event) self.event_to_object[f.fileno()] = f
Example #10
Source File: test_kqueue.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def testPair(self): kq = select.kqueue() a, b = socket.socketpair() a.send(b'foo') event1 = select.kevent(a, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE) event2 = select.kevent(b, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE) r = kq.control([event1, event2], 1, 1) self.assertTrue(r) self.assertFalse(r[0].flags & select.KQ_EV_ERROR) self.assertEqual(b.recv(r[0].data), b'foo') a.close() b.close() kq.close()
Example #11
Source File: test_kqueue.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def testPair(self): kq = select.kqueue() a, b = socket.socketpair() a.send(b'foo') event1 = select.kevent(a, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE) event2 = select.kevent(b, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE) r = kq.control([event1, event2], 1, 1) self.assertTrue(r) self.assertFalse(r[0].flags & select.KQ_EV_ERROR) self.assertEqual(b.recv(r[0].data), b'foo') a.close() b.close() kq.close()
Example #12
Source File: test_kqueue.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def testPair(self): kq = select.kqueue() a, b = socket.socketpair() a.send(b'foo') event1 = select.kevent(a, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE) event2 = select.kevent(b, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE) r = kq.control([event1, event2], 1, 1) self.assertTrue(r) self.assertFalse(r[0].flags & select.KQ_EV_ERROR) self.assertEqual(b.recv(r[0].data), b'foo') a.close() b.close() kq.close()
Example #13
Source File: test_kqueue.py From android_universal with MIT License | 5 votes |
def testPair(self): kq = select.kqueue() a, b = socket.socketpair() a.send(b'foo') event1 = select.kevent(a, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE) event2 = select.kevent(b, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE) r = kq.control([event1, event2], 1, 1) self.assertTrue(r) self.assertFalse(r[0].flags & select.KQ_EV_ERROR) self.assertEqual(b.recv(r[0].data), b'foo') a.close() b.close() kq.close()
Example #14
Source File: test_kqueue.py From ironpython2 with Apache License 2.0 | 5 votes |
def testPair(self): kq = select.kqueue() a, b = socket.socketpair() a.send(b'foo') event1 = select.kevent(a, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE) event2 = select.kevent(b, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE) r = kq.control([event1, event2], 1, 1) self.assertTrue(r) self.assertFalse(r[0].flags & select.KQ_EV_ERROR) self.assertEqual(b.recv(r[0].data), b'foo') a.close() b.close() kq.close()
Example #15
Source File: test_kqueue.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def testPair(self): kq = select.kqueue() a, b = socket.socketpair() a.send(b'foo') event1 = select.kevent(a, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE) event2 = select.kevent(b, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE) r = kq.control([event1, event2], 1, 1) self.assertTrue(r) self.assertFalse(r[0].flags & select.KQ_EV_ERROR) self.assertEqual(b.recv(r[0].data), b'foo') a.close() b.close() kq.close()
Example #16
Source File: event.py From fdslight with GNU General Public License v2.0 | 4 votes |
def __add_ev_read(self, fileno): """ Note:if the event exists,it will not do anything """ if fileno not in self.__rlist and self.__async_mode == "select": self.__rlist.append(fileno) if self.__async_mode == "epoll": if fileno not in self.__epoll_register_info: self.__epoll_register_info[fileno] = None eventmask = self.__epoll_register_info[fileno] event = select.EPOLLIN if eventmask == None: eventmask = event self.__epoll_object.register(fileno, eventmask) self.__epoll_register_info[fileno] = eventmask return is_register_read = (eventmask & select.EPOLLIN) == select.EPOLLIN if is_register_read == False: eventmask = event | eventmask self.__epoll_object.modify(fileno, eventmask) if self.__async_mode == "kqueue": filter_ = select.KQ_FILTER_READ flags = select.KQ_EV_ADD | select.KQ_EV_ENABLE if fileno not in self.__kqueue_event_map: kevent = select.kevent(fileno, filter_, flags) kevent.udata = 0 else: kevent = self.__kqueue_event_map[fileno] read_exists = (kevent.udata & EV_TYPE_READ) == EV_TYPE_READ if read_exists == False: kevent.filter = filter_ kevent.udata = (kevent.udata | EV_TYPE_READ) kevent.flags = flags if fileno not in self.__kqueue_change_event_map: self.__kqueue_change_event_map[fileno] = [] self.__kqueue_change_event_map[fileno].append(kevent) '''''' return
Example #17
Source File: event.py From fdslight with GNU General Public License v2.0 | 4 votes |
def __add_ev_write(self, fileno): if fileno not in self.__wlist and self.__async_mode == "select": self.__wlist.append(fileno) if self.__async_mode == "epoll": if fileno not in self.__epoll_register_info: self.__epoll_register_info[fileno] = None eventmask = self.__epoll_register_info[fileno] event = select.EPOLLOUT if eventmask == None: eventmask = event self.__epoll_object.register(fileno, eventmask) self.__epoll_register_info[fileno] = eventmask return is_register_write = (eventmask & select.EPOLLOUT) == select.EPOLLOUT if is_register_write == False: eventmask = event | eventmask self.__epoll_object.modify(fileno, eventmask) if self.__async_mode == "kqueue": filter_ = select.KQ_FILTER_WRITE flags = select.KQ_EV_ADD | select.KQ_EV_ENABLE if fileno not in self.__kqueue_event_map: kevent = select.kevent(fileno, filter_, flags) kevent.udata = 0 else: kevent = self.__kqueue_event_map[fileno] write_exists = (kevent.udata & EV_TYPE_WRITE) == EV_TYPE_WRITE if write_exists == False: kevent.filter = filter_ kevent.flags = flags kevent.udata = (kevent.udata | EV_TYPE_WRITE) if fileno not in self.__kqueue_change_event_map: self.__kqueue_change_event_map[fileno] = [] self.__kqueue_change_event_map[fileno].append(kevent) '''''' return