[issue30844] selectors: Add urgent data to read event

STINNER Victor report at bugs.python.org
Tue Sep 26 08:13:26 EDT 2017


STINNER Victor added the comment:

It would help to look how Twisted, eventlet, gevent and others handle "urgent data" and "exceptions". Check if they succeeded to formalize these events.

asyncore uses select() or poll().

asyncore.poll() uses select.select(). It adds the fd to exceptfds if the fd is in the readfds or writefds, then asyncore calls _exception():

        r = []; w = []; e = []
        for fd, obj in map.items():
            is_r = obj.readable()
            is_w = obj.writable()
            (...)
            if is_r or is_w:
                e.append(fd)
        (...)

        try:
            r, w, e = select.select(r, w, e, timeout)
        except select.error, err:
            (...)

        (...)

        for fd in e:
            obj = map.get(fd)
            if obj is None:
                continue
            _exception(obj)

asyncore.poll2() uses select.poll(). It only uses POLLPRI if the fd is readable but always checks for error condition (POLLERR) (if asyncio waits for read and/or write events):

        for fd, obj in map.items():
            flags = 0
            if obj.readable():
                flags |= select.POLLIN | select.POLLPRI
            # accepting sockets should not be writable
            if obj.writable() and not obj.accepting:
                flags |= select.POLLOUT
            if flags:
                # Only check for exceptions if object was either readable
                # or writable.
                flags |= select.POLLERR | select.POLLHUP | select.POLLNVAL
                pollster.register(fd, flags)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue30844>
_______________________________________


More information about the Python-bugs-list mailing list