classification
Title: Fix handling of sizehint=-1 in select.epoll()
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, giampaolo.rodola, serhiy.storchaka, taleinat, vstinner
Priority: normal Keywords: patch

Created on 2018-01-16 10:48 by taleinat, last changed 2018-06-30 13:16 by taleinat. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 7840 merged taleinat, 2018-06-21 06:45
PR 4265 taleinat, 2018-06-22 19:54
PR 8024 merged miss-islington, 2018-06-30 12:44
PR 8025 merged taleinat, 2018-06-30 12:56
Messages (9)
msg310072 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2018-01-16 10:48
In 2fb9ae9dfc5a6830d902332ba93b13387e292ddb, select.epoll() was changed to reject sizehint=-1, despite that still being documented as the default value. Would it be possible to reverse this change, making -1 a special value signaling select.epoll() to use sizehint=FD_SETSIZE-1, as was before this change?

Additionally, in the same commit the docs were changed to say that the sizehint parameter is deprecated and has no effect, but later changes have restored use of sizehint in certain cases without updating the documentation. This inconsistency should be fixed.

For reference, this came up as part of #31938.
msg310073 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2018-01-16 10:49
Also see discussion in GitHub PR 4265 for #31938.
msg310075 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-01-16 10:58
Also sizehint=0 was rejected before 2fb9ae9dfc5a6830d902332ba93b13387e292ddb. Now it is accepted.
msg320236 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-06-22 13:46
> *flags* is deprecated and completely ignored.

What if tomorrow, Linux accepts a new flag, passing the flag would just be ignored? Maybe it's fine. Especially usually Python developers only use flags exposed in Python, and currently, only EPOLL_CLOEXEC is exposed and this flag is useless in the specific case of Python (Python always uses the flag).
msg320238 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-06-22 14:06
> Also sizehint=0 was rejected before 2fb9ae9dfc5a6830d902332ba93b13387e292ddb. Now it is accepted.

DESCRIPTION
       epoll_create() creates a new epoll(7) instance.  Since Linux 2.6.8, the
       size argument is ignored, but must be  greater  than  zero;  see  NOTES
       below.

(...)

NOTES
       In  the  initial  epoll_create()  implementation,  the  size   argument
       informed  the  kernel of the number of file descriptors that the caller
       expected to add to the epoll instance.  The kernel used  this  informa‐
       tion  as a hint for the amount of space to initially allocate in inter‐
       nal data structures describing events.  (If necessary, the kernel would
       allocate  more  space  if the caller's usage exceeded the hint given in
       size.)  Nowadays, this hint is no longer required (the  kernel  dynami‐
       cally sizes the required data structures without needing the hint), but
       size must still be greater than zero, in order to ensure backward  com‐
       patibility when new epoll applications are run on older kernels.
msg320252 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2018-06-22 18:27
>> Also sizehint=0 was rejected before 2fb9ae9dfc5a6830d902332ba93b13387e292ddb. Now it is accepted.

Please note that by "Now it is accepted" I meant in the current codebase, before PR 7840. In this regard, that PR changes nothing.

Given the documentation quoted by Victor, perhaps it would be wise to review that earlier change.
msg320774 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2018-06-30 12:43
New changeset 0cdf5f42898350261c5ff65d96334e736130780f by Tal Einat in branch 'master':
bpo-32568: make select.epoll() and its docs consistent (#7840)
https://github.com/python/cpython/commit/0cdf5f42898350261c5ff65d96334e736130780f
msg320776 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2018-06-30 13:03
New changeset fd1c092bb9fee46d8d543710973c69a0e93a697a by Tal Einat (Miss Islington (bot)) in branch '3.7':
bpo-32568: make select.epoll() and its docs consistent (GH-7840) (GH-8024)
https://github.com/python/cpython/commit/fd1c092bb9fee46d8d543710973c69a0e93a697a
msg320778 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2018-06-30 13:15
New changeset db7ac30ef52ce35a4ead1bc1b9f0dd5331ed9779 by Tal Einat in branch '3.6':
[3.6] bpo-32568: make select.epoll() and its docs consistent (GH-7840) (GH-8025)
https://github.com/python/cpython/commit/db7ac30ef52ce35a4ead1bc1b9f0dd5331ed9779
History
Date User Action Args
2018-06-30 13:16:38taleinatsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-06-30 13:15:56taleinatsetmessages: + msg320778
2018-06-30 13:03:21taleinatsetmessages: + msg320776
2018-06-30 12:56:47taleinatsetpull_requests: + pull_request7635
2018-06-30 12:44:41miss-islingtonsetpull_requests: + pull_request7633
2018-06-30 12:43:25taleinatsetmessages: + msg320774
2018-06-25 13:51:41serhiy.storchakasetversions: + Python 3.8
2018-06-23 08:01:22giampaolo.rodolasetnosy: + giampaolo.rodola
2018-06-22 19:54:36taleinatsetpull_requests: + pull_request7470
2018-06-22 18:27:18taleinatsetmessages: + msg320252
2018-06-22 14:06:26vstinnersetmessages: + msg320238
2018-06-22 13:46:07vstinnersetnosy: + vstinner
messages: + msg320236
2018-06-21 06:45:25taleinatsetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request7449
2018-01-16 10:58:56serhiy.storchakasetmessages: + msg310075
2018-01-16 10:56:44serhiy.storchakasetstage: needs patch
type: behavior
components: + Extension Modules
versions: + Python 3.6, Python 3.7
2018-01-16 10:49:40taleinatsetmessages: + msg310073
2018-01-16 10:48:25taleinatcreate