当前位置: 首页>>代码示例>>Python>>正文


Python select.POLLOUT属性代码示例

本文整理汇总了Python中select.POLLOUT属性的典型用法代码示例。如果您正苦于以下问题:Python select.POLLOUT属性的具体用法?Python select.POLLOUT怎么用?Python select.POLLOUT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在select的用法示例。


在下文中一共展示了select.POLLOUT属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _parse_events

# 需要导入模块: import select [as 别名]
# 或者: from select import POLLOUT [as 别名]
def _parse_events(self, events):
        """Parse ``events``.

        ``events`` is a list of events as returned by
        :meth:`select.poll.poll()`.

        Yield all parsed events.

        """
        for fd, event_mask in events:
            if self._has_event(event_mask, select.POLLNVAL):
                raise IOError('File descriptor not open: {0!r}'.format(fd))
            elif self._has_event(event_mask, select.POLLERR):
                raise IOError('Error while polling fd: {0!r}'.format(fd))

            if self._has_event(event_mask, select.POLLIN):
                yield fd, 'r'
            if self._has_event(event_mask, select.POLLOUT):
                yield fd, 'w'
            if self._has_event(event_mask, select.POLLHUP):
                yield fd, 'h' 
开发者ID:mbusb,项目名称:multibootusb,代码行数:23,代码来源:poll.py

示例2: poll_wait_for_socket

# 需要导入模块: import select [as 别名]
# 或者: from select import POLLOUT [as 别名]
def poll_wait_for_socket(sock, read=False, write=False, timeout=None):
    if not read and not write:
        raise RuntimeError("must specify at least one of read=True, write=True")
    mask = 0
    if read:
        mask |= select.POLLIN
    if write:
        mask |= select.POLLOUT
    poll_obj = select.poll()
    poll_obj.register(sock, mask)

    # For some reason, poll() takes timeout in milliseconds
    def do_poll(t):
        if t is not None:
            t *= 1000
        return poll_obj.poll(t)

    return bool(_retry_on_intr(do_poll, timeout)) 
开发者ID:danielecook,项目名称:gist-alfred,代码行数:20,代码来源:wait.py

示例3: select

# 需要导入模块: import select [as 别名]
# 或者: from select import POLLOUT [as 别名]
def select(self, timeout=None):
            if timeout is None:
                timeout = None
            elif timeout <= 0:
                timeout = 0
            else:
                # poll() has a resolution of 1 millisecond, round away from
                # zero to wait *at least* timeout seconds.
                timeout = int(math.ceil(timeout * 1e3))
            ready = []
            try:
                fd_event_list = wrap_error(self._poll.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

示例4: pollmask_to_str

# 需要导入模块: import select [as 别名]
# 或者: from select import POLLOUT [as 别名]
def pollmask_to_str(mask):
        """
        Conver pool mast to string

        :param mask: poll return mask
        """
        out = ""
        if (mask & select.POLLIN):
            out += "IN "
        if (mask & select.POLLPRI):
            out += "PRI IN "
        if (mask & select.POLLOUT):
            out += "OUT "
        if (mask & select.POLLERR):
            out += "ERR "
        if (mask & select.POLLHUP):
            out += "HUP "
        if (mask & select.POLLMSG):
            out += "MSG "
        return out 
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:22,代码来源:virtio_console_guest.py

示例5: poll

# 需要导入模块: import select [as 别名]
# 或者: from select import POLLOUT [as 别名]
def poll(self):
        r, w, x = select.select(self.readable(), self.writable(), self.exceptional())

        events = {} 
        self.collate_events(r, select.POLLIN, events)
        self.collate_events(w, select.POLLOUT, events)
        self.collate_events(x, select.POLLPRI, events)

        final_events = []
        for fd in events:
            mask = 0

            for event in events[fd]:
                mask |= event

            final_events.append([ fd, mask ])

        return final_events 
开发者ID:pycepa,项目名称:pycepa,代码行数:20,代码来源:Select.py

示例6: register

# 需要导入模块: import select [as 别名]
# 或者: from select import POLLOUT [as 别名]
def register(self, fileobj, events, data=None):
            key = super(PollSelector, self).register(fileobj, events, data)
            event_mask = 0
            if events & EVENT_READ:
                event_mask |= select.POLLIN
            if events & EVENT_WRITE:
                event_mask |= select.POLLOUT
            self._poll.register(key.fd, event_mask)
            return key 
开发者ID:snowflakedb,项目名称:snowflake-connector-python,代码行数:11,代码来源:ssl_wrap_util.py

示例7: select

# 需要导入模块: import select [as 别名]
# 或者: from select import POLLOUT [as 别名]
def select(self, timeout=None):
            ready = []
            fd_events = _syscall_wrapper(self._wrap_poll, True, timeout=timeout)
            for fd, event_mask in fd_events:
                events = 0
                if event_mask & ~select.POLLIN:
                    events |= EVENT_WRITE
                if event_mask & ~select.POLLOUT:
                    events |= EVENT_READ

                key = self._key_from_fd(fd)
                if key:
                    ready.append((key, events & key.events))

            return ready 
开发者ID:snowflakedb,项目名称:snowflake-connector-python,代码行数:17,代码来源:ssl_wrap_util.py


注:本文中的select.POLLOUT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。