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.

classification
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
process
Status: closed Resolution: duplicate
Dependencies: Superseder: selectors.SelectSelectors fails if select.select 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.

Files
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 self.select 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, select.select) 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 select.select 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?

[1] https://github.com/berkerpeksag/selectors34/pull/4
[2] https://github.com/berkerpeksag/selectors34/issues/5
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+(https://github.com/gevent/gevent/blob/master/src/gevent/monkey.py#L497) 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 https://github.com/berkerpeksag/selectors34/pull/4.
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.
History
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 select.select 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