當前位置: 首頁>>代碼示例>>Python>>正文


Python select.devpoll方法代碼示例

本文整理匯總了Python中select.devpoll方法的典型用法代碼示例。如果您正苦於以下問題:Python select.devpoll方法的具體用法?Python select.devpoll怎麽用?Python select.devpoll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在select的用法示例。


在下文中一共展示了select.devpoll方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: select

# 需要導入模塊: import select [as 別名]
# 或者: from select import devpoll [as 別名]
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 
開發者ID:jpush,項目名稱:jbox,代碼行數:27,代碼來源:selectors.py

示例2: test_close

# 需要導入模塊: import select [as 別名]
# 或者: from select import devpoll [as 別名]
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) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:25,代碼來源:test_devpoll.py

示例3: test_timeout_overflow

# 需要導入模塊: import select [as 別名]
# 或者: from select import devpoll [as 別名]
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) 
開發者ID:IronLanguages,項目名稱:ironpython3,代碼行數:18,代碼來源:test_devpoll.py

示例4: __init__

# 需要導入模塊: import select [as 別名]
# 或者: from select import devpoll [as 別名]
def __init__(self):
            super(DevpollSelector, self).__init__()
            self._devpoll = select.devpoll() 
開發者ID:jpush,項目名稱:jbox,代碼行數:5,代碼來源:selectors.py

示例5: close

# 需要導入模塊: import select [as 別名]
# 或者: from select import devpoll [as 別名]
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) 
開發者ID:jpush,項目名稱:jbox,代碼行數:9,代碼來源:selectors.py

示例6: fileno

# 需要導入模塊: import select [as 別名]
# 或者: from select import devpoll [as 別名]
def fileno(self):
                """Return devpoll() fd."""
                return self._poller.fileno() 
開發者ID:aliyun,項目名稱:oss-ftp,代碼行數:5,代碼來源:ioloop.py

示例7: __init__

# 需要導入模塊: import select [as 別名]
# 或者: from select import devpoll [as 別名]
def __init__(self):
            super().__init__()
            self._devpoll = select.devpoll() 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:5,代碼來源:selectors.py

示例8: close

# 需要導入模塊: import select [as 別名]
# 或者: from select import devpoll [as 別名]
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) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:10,代碼來源:selectors.py

示例9: test_devpoll

# 需要導入模塊: import select [as 別名]
# 或者: from select import devpoll [as 別名]
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) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:11,代碼來源:eintr_tester.py

示例10: test_fd_non_inheritable

# 需要導入模塊: import select [as 別名]
# 或者: from select import devpoll [as 別名]
def test_fd_non_inheritable(self):
        devpoll = select.devpoll()
        self.addCleanup(devpoll.close)
        self.assertEqual(os.get_inheritable(devpoll.fileno()), False) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:6,代碼來源:test_devpoll.py

示例11: test_events_mask_overflow

# 需要導入模塊: import select [as 別名]
# 或者: from select import devpoll [as 別名]
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) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:11,代碼來源:test_devpoll.py

示例12: test_events_mask_overflow_c_limits

# 需要導入模塊: import select [as 別名]
# 或者: from select import devpoll [as 別名]
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) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:10,代碼來源:test_devpoll.py

示例13: close

# 需要導入模塊: import select [as 別名]
# 或者: from select import devpoll [as 別名]
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) 
開發者ID:CedricGuillemet,項目名稱:Imogen,代碼行數:10,代碼來源:selectors.py


注:本文中的select.devpoll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。