This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pklanke
Recipients neologix, pitrou, pklanke, vstinner, yselivanov
Date 2017-09-27.07:48:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <14e1793c-70f3-0306-174c-ef230aacacef@protonic.nl>
In-reply-to <1506428006.24.0.821361150906.issue30844@psf.upfronthosting.co.za>
Content
On 26-09-17 14:13, STINNER Victor wrote:
> 
> STINNER Victor added the comment:
> 
> It would help to look how Twisted, eventlet, gevent and others handle "urgent data" and "exceptions". 
First of all, there are no exceptions, only "exceptional conditions". 
Second of all, There is no "urgent data" AND "exceptional conditions"; 
"urgent data" is one of possible exceptional conditions, but not all 
exceptional conditions mean there is urgent data to read.

Check if they succeeded to formalize these events.
IMO, they have made it more confusing by using the word 'exception'. In 
this case I would have stuck with 'exceptional'. But at least it is 
better than having to replace it with 'urgent data'
> 
> 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):
It registers for POLLERR, POLLHUP and POLLNVAL, events one does need not 
to subscribe for. These events are output events only and should not be 
added to mask.
> 
>          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)
> 
Adding POLLPRI to the flags if fd is readable doesn't cut it when using 
it with sysfs gpio kernel driver. The fd for a sysfs input is ALWAYS 
readable. We want to ONLY wake on POLLPRI event.
> ----------
> 
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue30844>
> _______________________________________
>
History
Date User Action Args
2017-09-27 07:48:47pklankesetrecipients: + pklanke, pitrou, vstinner, neologix, yselivanov
2017-09-27 07:48:47pklankelinkissue30844 messages
2017-09-27 07:48:47pklankecreate