當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。