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.

classification
Title: asyncio: selector_events: add_urgent() for urgent data to read, 3rd argument of select.select()
Type: enhancement Stage:
Components: asyncio Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, pklanke, vstinner, yselivanov
Priority: normal Keywords:

Created on 2017-07-04 13:51 by pklanke, last changed 2022-04-11 14:58 by admin.

Messages (9)
msg297652 - (view) Author: Pim Klanke (pklanke) * Date: 2017-07-04 13:51
depends on bpo-30844
msg297653 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-07-04 13:54
Please elaborate the description :-)
msg297654 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-07-04 13:55
Does the Windows Proactor event loop has a similar concept of "excepter"?
msg297655 - (view) Author: Pim Klanke (pklanke) * Date: 2017-07-04 14:15
To be able to use GPIO Sysfs Interface with asyncio on our embedded platforms, we require exceptional event support in asyncio.

depends on bpo-30844
msg297722 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-07-05 09:24
In the selectors issue, we discussed how an application should prioritize "urgent" events:
http://bugs.python.org/issue30844#msg297707

While I now agree that it's not the role of selectors to decide, I would like to discuss the plan for asyncio.

Let's say that we got read event on sockets A and B (in an ordered list from selectors: A, then B), but B gets urgent data: should we handle B urgent data before not-urgent A data?

Would it be possible to let the developer decide how to prioritize events?

How does Twisted or Node.JS handle urgent data?
msg297765 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2017-07-05 15:09
How do you define "urgent data"? Is this just the third category of select(), Read, Write, Exceptional? I don't know if that should be considered urgent, it's just "out of band" IIRC.
msg297809 - (view) Author: Pim Klanke (pklanke) * Date: 2017-07-06 07:07
This is in fact the third catagory of select(), "exceptional conditions", but because some find the term "exceptional" confusing when used in a Python module, we decided to use the term "urgent data", borrowed from the poll(2) man page. (see bpo-30844)

An example of an exceptional conditions event is "out of band", another one is edge detection from GPIO Sysfs Interface.

The patch for fulfilling this issue can and will be supplied if and when bpo-30844 is merged. 30844 originally also contained the patch to asyncio, but I was asked to split it into two separate patches.
msg297821 - (view) Author: Pim Klanke (pklanke) * Date: 2017-07-06 10:22
> "Let's say that we got read event on sockets A and B (in an ordered list from selectors: A, then B), but B gets urgent data: should we handle B urgent data before not-urgent A data?"

IMO No. The same strategy applies. urgent data events on B have priority over other events on B, but not necessarily over events on A. As long as the urgent data events for a certain file object are handled before other events for that file object, it should be fine.

> "Would it be possible to let the developer decide how to prioritize events?"
At this point asyncio has no support for prioritizing event handlers. If prioritizing should be necessary, it should IMO be implemented in a way that all event handlers can be prioritized and not just these events. I think we can agree that this falls outside the scope of this patch.
msg297823 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-07-06 11:22
Ok, it makes sense. Thanks :-)
History
Date User Action Args
2022-04-11 14:58:48adminsetgithub: 75030
2017-07-06 11:22:47vstinnersetmessages: + msg297823
2017-07-06 10:22:25pklankesetmessages: + msg297821
2017-07-06 07:07:56pklankesetmessages: + msg297809
2017-07-05 15:09:54gvanrossumsetmessages: + msg297765
2017-07-05 09:24:38vstinnersetnosy: + gvanrossum
messages: + msg297722
2017-07-05 06:48:26pklankesettitle: asyncio: selector_events: add_excepter(), 3rd argument of select.select() -> asyncio: selector_events: add_urgent() for urgent data to read, 3rd argument of select.select()
2017-07-04 14:15:26pklankesetmessages: + msg297655
2017-07-04 13:55:09vstinnersetmessages: + msg297654
2017-07-04 13:54:28vstinnersetnosy: + vstinner
messages: + msg297653
2017-07-04 13:51:23pklankecreate