Python select.devpoll() Examples
The following are 30
code examples of select.devpoll().
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_devpoll.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def test_close(self): open_file = open(__file__, "rb") self.addCleanup(open_file.close) fd = open_file.fileno() devpoll = select.devpoll() # test fileno() method and closed attribute self.assertIsInstance(devpoll.fileno(), int) self.assertFalse(devpoll.closed) # test close() devpoll.close() self.assertTrue(devpoll.closed) self.assertRaises(ValueError, devpoll.fileno) # close() can be called more than once devpoll.close() # operations must fail with ValueError("I/O operation on closed ...") self.assertRaises(ValueError, devpoll.modify, fd, select.POLLIN) self.assertRaises(ValueError, devpoll.poll) self.assertRaises(ValueError, devpoll.register, fd, fd, select.POLLIN) self.assertRaises(ValueError, devpoll.unregister, fd)
Example #2
Source File: selectors.py From Flask-P2P with MIT License | 6 votes |
def select(self, timeout=None): if timeout is None: timeout = None elif timeout <= 0: timeout = 0 else: # devpoll() has a resolution of 1 millisecond, round away from # zero to wait *at least* timeout seconds. timeout = math.ceil(timeout * 1e3) ready = [] try: fd_event_list = self._devpoll.poll(timeout) except InterruptedError: return ready for fd, event in fd_event_list: events = 0 if event & ~select.POLLIN: events |= EVENT_WRITE if event & ~select.POLLOUT: events |= EVENT_READ key = self._key_from_fd(fd) if key: ready.append((key, events & key.events)) return ready
Example #3
Source File: test_devpoll.py From ironpython3 with Apache License 2.0 | 6 votes |
def test_close(self): open_file = open(__file__, "rb") self.addCleanup(open_file.close) fd = open_file.fileno() devpoll = select.devpoll() # test fileno() method and closed attribute self.assertIsInstance(devpoll.fileno(), int) self.assertFalse(devpoll.closed) # test close() devpoll.close() self.assertTrue(devpoll.closed) self.assertRaises(ValueError, devpoll.fileno) # close() can be called more than once devpoll.close() # operations must fail with ValueError("I/O operation on closed ...") self.assertRaises(ValueError, devpoll.modify, fd, select.POLLIN) self.assertRaises(ValueError, devpoll.poll) self.assertRaises(ValueError, devpoll.register, fd, fd, select.POLLIN) self.assertRaises(ValueError, devpoll.unregister, fd)
Example #4
Source File: test_devpoll.py From ironpython3 with Apache License 2.0 | 6 votes |
def test_timeout_overflow(self): pollster = select.devpoll() w, r = os.pipe() pollster.register(w) pollster.poll(-1) self.assertRaises(OverflowError, pollster.poll, -2) self.assertRaises(OverflowError, pollster.poll, -1 << 31) self.assertRaises(OverflowError, pollster.poll, -1 << 64) pollster.poll(0) pollster.poll(1) pollster.poll(1 << 30) self.assertRaises(OverflowError, pollster.poll, 1 << 31) self.assertRaises(OverflowError, pollster.poll, 1 << 63) self.assertRaises(OverflowError, pollster.poll, 1 << 64)
Example #5
Source File: selectors.py From annotated-py-projects with MIT License | 6 votes |
def select(self, timeout=None): if timeout is None: timeout = None elif timeout <= 0: timeout = 0 else: # devpoll() has a resolution of 1 millisecond, round away from # zero to wait *at least* timeout seconds. timeout = math.ceil(timeout * 1e3) ready = [] try: fd_event_list = self._devpoll.poll(timeout) except InterruptedError: return ready for fd, event in fd_event_list: events = 0 if event & ~select.POLLIN: events |= EVENT_WRITE if event & ~select.POLLOUT: events |= EVENT_READ key = self._key_from_fd(fd) if key: ready.append((key, events & key.events)) return ready
Example #6
Source File: selectors.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
def select(self, timeout=None): if timeout is None: timeout = None elif timeout <= 0: timeout = 0 else: # devpoll() has a resolution of 1 millisecond, round away from # zero to wait *at least* timeout seconds. timeout = math.ceil(timeout * 1e3) ready = [] try: fd_event_list = self._devpoll.poll(timeout) except InterruptedError: return ready for fd, event in fd_event_list: events = 0 if event & ~select.POLLIN: events |= EVENT_WRITE if event & ~select.POLLOUT: events |= EVENT_READ key = self._key_from_fd(fd) if key: ready.append((key, events & key.events)) return ready
Example #7
Source File: test_devpoll.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
def test_close(self): open_file = open(__file__, "rb") self.addCleanup(open_file.close) fd = open_file.fileno() devpoll = select.devpoll() # test fileno() method and closed attribute self.assertIsInstance(devpoll.fileno(), int) self.assertFalse(devpoll.closed) # test close() devpoll.close() self.assertTrue(devpoll.closed) self.assertRaises(ValueError, devpoll.fileno) # close() can be called more than once devpoll.close() # operations must fail with ValueError("I/O operation on closed ...") self.assertRaises(ValueError, devpoll.modify, fd, select.POLLIN) self.assertRaises(ValueError, devpoll.poll) self.assertRaises(ValueError, devpoll.register, fd, fd, select.POLLIN) self.assertRaises(ValueError, devpoll.unregister, fd)
Example #8
Source File: selectors.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def select(self, timeout=None): if timeout is None: timeout = None elif timeout <= 0: timeout = 0 else: # devpoll() has a resolution of 1 millisecond, round away from # zero to wait *at least* timeout seconds. timeout = math.ceil(timeout * 1e3) ready = [] try: fd_event_list = self._devpoll.poll(timeout) except InterruptedError: return ready for fd, event in fd_event_list: events = 0 if event & ~select.POLLIN: events |= EVENT_WRITE if event & ~select.POLLOUT: events |= EVENT_READ key = self._key_from_fd(fd) if key: ready.append((key, events & key.events)) return ready
Example #9
Source File: selectors.py From jbox with MIT License | 6 votes |
def select(self, timeout=None): if timeout is None: timeout = None elif timeout <= 0: timeout = 0 else: # devpoll() has a resolution of 1 millisecond, round away from # zero to wait *at least* timeout seconds. timeout = math.ceil(timeout * 1e3) ready = [] try: fd_event_list = self._devpoll.poll(timeout) except InterruptedError: return ready for fd, event in fd_event_list: events = 0 if event & ~select.POLLIN: events |= EVENT_WRITE if event & ~select.POLLOUT: events |= EVENT_READ key = self._key_from_fd(fd) if key: ready.append((key, events & key.events)) return ready
Example #10
Source File: test_devpoll.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_fd_non_inheritable(self): devpoll = select.devpoll() self.addCleanup(devpoll.close) self.assertEqual(os.get_inheritable(devpoll.fileno()), False)
Example #11
Source File: test_devpoll.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_events_mask_overflow(self): pollster = select.devpoll() w, r = os.pipe() pollster.register(w) # Issue #17919 self.assertRaises(OverflowError, pollster.register, 0, -1) self.assertRaises(OverflowError, pollster.register, 0, 1 << 64) self.assertRaises(OverflowError, pollster.modify, 1, -1) self.assertRaises(OverflowError, pollster.modify, 1, 1 << 64)
Example #12
Source File: eintr_tester.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_devpoll(self): poller = select.devpoll() self.addCleanup(poller.close) t0 = time.monotonic() poller.poll(self.sleep_time * 1e3) dt = time.monotonic() - t0 self.stop_alarm() self.assertGreaterEqual(dt, self.sleep_time)
Example #13
Source File: eintr_tester.py From android_universal with MIT License | 5 votes |
def test_devpoll(self): poller = select.devpoll() self.addCleanup(poller.close) t0 = time.monotonic() poller.poll(self.sleep_time * 1e3) dt = time.monotonic() - t0 self.stop_alarm() self.assertGreaterEqual(dt, self.sleep_time)
Example #14
Source File: selectors.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def close(self): self._kqueue.close() super().close() # Choose the best implementation, roughly: # epoll|kqueue|devpoll > poll > select. # select() also can't accept a FD > FD_SETSIZE (usually around 1024)
Example #15
Source File: test_devpoll.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_events_mask_overflow_c_limits(self): from _testcapi import USHRT_MAX pollster = select.devpoll() w, r = os.pipe() pollster.register(w) # Issue #17919 self.assertRaises(OverflowError, pollster.register, 0, USHRT_MAX + 1) self.assertRaises(OverflowError, pollster.modify, 1, USHRT_MAX + 1)
Example #16
Source File: selectors.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def __init__(self): super().__init__() self._devpoll = select.devpoll()
Example #17
Source File: selectors.py From annotated-py-projects with MIT License | 5 votes |
def close(self): self._kqueue.close() super().close() # Choose the best implementation, roughly: # epoll|kqueue|devpoll > poll > select. # select() also can't accept a FD > FD_SETSIZE (usually around 1024)
Example #18
Source File: ioloop.py From pyftpdlib with MIT License | 5 votes |
def fileno(self): """Return devpoll() fd.""" return self._poller.fileno()
Example #19
Source File: selectors.py From android_universal with MIT License | 5 votes |
def close(self): self._selector.close() super().close() # Choose the best implementation, roughly: # epoll|kqueue|devpoll > poll > select. # select() also can't accept a FD > FD_SETSIZE (usually around 1024)
Example #20
Source File: selectors.py From jbox with MIT License | 5 votes |
def __init__(self): super(DevpollSelector, self).__init__() self._devpoll = select.devpoll()
Example #21
Source File: selectors.py From annotated-py-projects with MIT License | 5 votes |
def __init__(self): super().__init__() self._devpoll = select.devpoll()
Example #22
Source File: selectors.py From Flask-P2P with MIT License | 5 votes |
def close(self): self._kqueue.close() super(KqueueSelector, self).close() # Choose the best implementation: roughly, epoll|kqueue|devpoll > poll > select. # select() also can't accept a FD > FD_SETSIZE (usually around 1024)
Example #23
Source File: test_devpoll.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_events_mask_overflow(self): pollster = select.devpoll() w, r = os.pipe() pollster.register(w) # Issue #17919 self.assertRaises(OverflowError, pollster.register, 0, -1) self.assertRaises(OverflowError, pollster.register, 0, 1 << 64) self.assertRaises(OverflowError, pollster.modify, 1, -1) self.assertRaises(OverflowError, pollster.modify, 1, 1 << 64)
Example #24
Source File: selectors.py From jbox with MIT License | 5 votes |
def close(self): self._kqueue.close() super(KqueueSelector, self).close() # Choose the best implementation: roughly, epoll|kqueue|devpoll > poll > select. # select() also can't accept a FD > FD_SETSIZE (usually around 1024)
Example #25
Source File: ioloop.py From oss-ftp with MIT License | 5 votes |
def fileno(self): """Return devpoll() fd.""" return self._poller.fileno()
Example #26
Source File: ioloop.py From oss-ftp with MIT License | 5 votes |
def fileno(self): """Return devpoll() fd.""" return self._poller.fileno()
Example #27
Source File: ioloop.py From script-languages with MIT License | 5 votes |
def fileno(self): """Return devpoll() fd.""" return self._poller.fileno()
Example #28
Source File: selectors.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def __init__(self): super().__init__() self._devpoll = select.devpoll()
Example #29
Source File: selectors.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def close(self): self._kqueue.close() super().close() # Choose the best implementation, roughly: # epoll|kqueue|devpoll > poll > select. # select() also can't accept a FD > FD_SETSIZE (usually around 1024)
Example #30
Source File: eintr_tester.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_devpoll(self): poller = select.devpoll() self.addCleanup(poller.close) t0 = time.monotonic() poller.poll(self.sleep_time * 1e3) dt = time.monotonic() - t0 self.stop_alarm() self.assertGreaterEqual(dt, self.sleep_time)