当前位置: 首页>>代码示例>>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;未经允许,请勿转载。