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 vstinner
Recipients gvanrossum, neologix, vstinner
Date 2013-10-31.22:36:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1383258981.48.0.274242938687.issue19465@psf.upfronthosting.co.za>
In-reply-to
Content
multiprocess, telnetlib (and subprocess in a near future, see #18923) use the following code to select the best selector:

# poll/select have the advantage of not requiring any extra file descriptor,
# contrarily to epoll/kqueue (also, they require a single syscall).
if hasattr(selectors, 'PollSelector'):
    _TelnetSelector = selectors.PollSelector
else:
    _TelnetSelector = selectors.SelectSelector

I don't like the principle of "a default selector", selectors.DefaultSelector should be removed in my opinion.

I would prefer a function returning the best selector using constraints. Example:

def get_selector(use_fd=True) -> BaseSelector:
  ...

By default, it would return the same than the current DefaultSelector. But if you set use_fd=False, the choice would be restricted to select() or poll().

I don't want to duplicate code like telnetlib uses in each module, it's harder to maintain. The selectors module may get new selectors in the future, see for example #18931.

Except use_fd, I don't have other ideas of constraints. I read somewhere that differenet selectors may have different limits on the number of file descriptors. I don't know if it's useful to use such constraint?
History
Date User Action Args
2013-10-31 22:36:21vstinnersetrecipients: + vstinner, gvanrossum, neologix
2013-10-31 22:36:21vstinnersetmessageid: <1383258981.48.0.274242938687.issue19465@psf.upfronthosting.co.za>
2013-10-31 22:36:21vstinnerlinkissue19465 messages
2013-10-31 22:36:21vstinnercreate