STINNER Victor added the comment:

> "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 ;-)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30844>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to