Message198988
This adds a keys() method to selectors, to return all the registered keys.
It's useful, because one often needs to loop until all registered file objects have been unregistered e.g. (inspired from subprocess, see #18923):
while selector.keys():
for key, events in selector.select():
# process events
also, it can be useful if you want e.g. the list of all currently logged users, etc. It avoids having to maintain a separate data-structure tracking registered file objects.
The patch attached returns a new set upon each call: another way to handle this would be to just return the dictionary's .values() view: it would be faster and use less memory, but it's immutable and also this would prevent the user from doing:
for key in selectior.keys():
if somecondition:
selector.unregister(key.fileobj)
(since you'll get "dictonary changed size during iteration"). |
|
Date |
User |
Action |
Args |
2013-10-05 14:40:38 | neologix | set | recipients:
+ neologix, pitrou, vstinner |
2013-10-05 14:40:38 | neologix | set | messageid: <1380984038.36.0.521182029078.issue19172@psf.upfronthosting.co.za> |
2013-10-05 14:40:38 | neologix | link | issue19172 messages |
2013-10-05 14:40:37 | neologix | create | |
|