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.

Title: Uniform SelectSelector._select behavior
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.7, Python 3.6, Python 3.4, Python 3.5
Status: closed Resolution: duplicate
Dependencies: Superseder: selectors.SelectSelectors fails if was patched
View: 27634
Assigned To: Nosy List: Wen Adam, berker.peksag, neologix, vstinner
Priority: normal Keywords: patch

Created on 2017-01-20 08:29 by Wen Adam, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit
uniform_select_behaviour.patch Wen Adam, 2017-01-20 08:29
Messages (5)
msg285891 - (view) Author: Wen Adam (Wen Adam) * Date: 2017-01-20 08:29
SelectSelector._select is differently on different platforms.

On win32, SelectSelector._select is a unbound/bound method and pass instance as the first argument, but on *nix, SelectSelector._select is a builtin_function_or_method(Although still works)

If someone want to replace(or patch) select, he must implement two select function(one is a function, the other is a instance method), 
Otherwise you will get「TypeError: select() takes at most 4 arguments (5 given)」.

And I think make built-in funtion(like len, as a class attr/method is a black magic(it's still a function) and hard to maintain
msg285928 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2017-01-21 00:44
Thanks for the report! This is a duplicate of issue 27634.

Since we got multiple reports [1][2] about the same problem on selectors34 (backport of selector module) and use of Gevent is very popular, I think we should reconsider the idea of wrapping with staticmethod().

Also, if I remember correctly, this was fixed on Gevent's side before (although I know that you didn't mention Gevent in your report)

Victor and Charles-François, what do you think?

msg285935 - (view) Author: Wen Adam (Wen Adam) * Date: 2017-01-21 03:45
Thx for your replying, Peksag.

I encountered this problem is really because of Gevent and Selector34. Gevent fixed this issue but only works for python3.4+( by a tricking way. python 2.x still has this problem
msg285936 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2017-01-21 04:15
Great! Since this is no longer an issue on Python 3.4+, I'm going to close this as a duplicate of issue 27634 and merge
msg285937 - (view) Author: Wen Adam (Wen Adam) * Date: 2017-01-21 04:33
I know it works on python3.4, but black magic still exists in selectors lib,and 3rd-party module have to prepare two function to make compatibility.
Date User Action Args
2022-04-11 14:58:42adminsetgithub: 73518
2017-01-21 04:33:58Wen Adamsetmessages: + msg285937
2017-01-21 04:15:01berker.peksagsetstatus: open -> closed
superseder: selectors.SelectSelectors fails if was patched
messages: + msg285936

resolution: duplicate
stage: resolved
2017-01-21 03:45:59Wen Adamsetmessages: + msg285935
2017-01-21 00:44:57berker.peksagsetnosy: + berker.peksag, vstinner
messages: + msg285928
2017-01-20 08:29:05Wen Adamcreate