Message297707
> "urgent data", "High-priority data"
How is an application supposed to handle these data? Read them before any other data?
The selectors API returns a list of (key, events) tuples. So an application has to iterate on this list twice? A first time to look for urgent data, and then iterate again to handle other events?
Pseudo-code:
ready = selector.select(timeout)
for key, events in ready:
if events & selectors.EVENT_URGENT:
process_urgent_event(key, events)
for key, events in ready:
process_other_events(key, events)
I just want to make sure that I understand correctly how these events should be used.
Would it be worth it to provide an helper to group urgent event and other events? Maybe a new select_urgent() method which would return two lists?
A selector which creates the ready list already knows if an event is urgent or not, and so could directly group them in two separated lists.
"Urgent event" doens't mean that key.events would only contain EVENT_URGENT, it can contain other events. So maybe the grouping function should be something like:
---
ready_urgent = []
ready = []
for ...:
key = ...
events = ...
if not key:
continue
if events == EVENT_URGENT:
ready_urgent.append((key, key.events & events))
elif events & EVENT_URGENT:
ready_urgent.append((key, key.events & events))
ready.append((key, key.events & events))
else:
ready.append((key, key.events & events))
---
I don't know if it makes sense :-) Maybe it's better to let applications handle that themself ;-) |
|
Date |
User |
Action |
Args |
2017-07-05 07:32:03 | vstinner | set | recipients:
+ vstinner, pitrou, neologix, yselivanov, pklanke |
2017-07-05 07:32:03 | vstinner | set | messageid: <1499239923.68.0.10670982913.issue30844@psf.upfronthosting.co.za> |
2017-07-05 07:32:03 | vstinner | link | issue30844 messages |
2017-07-05 07:32:03 | vstinner | create | |
|