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 neologix
Recipients neologix, pitrou, vstinner
Date 2013-10-05.14:40:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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
       # 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:

(since you'll get "dictonary changed size during iteration").
Date User Action Args
2013-10-05 14:40:38neologixsetrecipients: + neologix, pitrou, vstinner
2013-10-05 14:40:38neologixsetmessageid: <>
2013-10-05 14:40:38neologixlinkissue19172 messages
2013-10-05 14:40:37neologixcreate