Open
Labels
3.8 (EOL)end of lifeOS-windowsextension-modulesC modules in the Modules dirtopic-socketRelated to the socket, socketserver and selectors modulestype-featureA feature request or enhancement
Description
| BPO | 34934 |
|---|---|
| Nosy | @pfmoore, @giampaolo, @tjguk, @zware, @zooba |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee = None
closed_at = None
created_at = <Date 2018-10-08.14:32:57.564>
labels = ['extension-modules', 'type-feature', '3.8', 'OS-windows']
title = 'Consider making Windows select.select interruptible using WSAEventSelect & WSAWaitForMultipleEvents'
updated_at = <Date 2018-10-09.16:13:33.120>
user = 'https://bugs.python.org/ondrejkutal'bugs.python.org fields:
activity = <Date 2018-10-09.16:13:33.120>
actor = 'giampaolo.rodola'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Extension Modules', 'Windows']
creation = <Date 2018-10-08.14:32:57.564>
creator = 'ondrej.kutal'
dependencies = []
files = []
hgrepos = []
issue_num = 34934
keywords = []
message_count = 1.0
messages = ['327354']
nosy_count = 6.0
nosy_names = ['paul.moore', 'giampaolo.rodola', 'tim.golden', 'zach.ware', 'steve.dower', 'ondrej.kutal']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue34934'
versions = ['Python 3.8']Metadata
Metadata
Assignees
Labels
3.8 (EOL)end of lifeOS-windowsextension-modulesC modules in the Modules dirtopic-socketRelated to the socket, socketserver and selectors modulestype-featureA feature request or enhancement
Activity
ondrejkutal commentedon Oct 8, 2018
At the moment, socket select.select() function is not interruptable on Windows OS (in main thread). Following code cannot be interrupted (for example by CTRL+C):
However this can be achieved by replacing select() calls with use of Windows native APIs WSAEventSelect and WSAWaitForMultipleEvents (see for example https://stackoverflow.com/questions/10353017). I have tried a quick prototype in selectmodule.c, replacing
Py_BEGIN_ALLOW_THREADS
errno = 0;
n = select(max, &ifdset, &ofdset, &efdset, tvp);
Py_END_ALLOW_THREADS
with
#endif
and then I was able to interrupt the script above. I noticed slight performance loss when having timeout 0, repeating select 1000 times it took ~2000 us, wile after this update it took ~3000 us.
I am just throwing it here to consider as a possibility. Clearly my code above is just proof of concept, modification would be needed (include write fd, some proper fd limit, possibly check multiple times to get actual number of ready fds, etc...).
[-]Consider making Windows select.select interruptable using WSAEventSelect & WSAWaitForMultipleEvents[/-][+]Consider making Windows select.select interruptible using WSAEventSelect & WSAWaitForMultipleEvents[/+]Chronial commentedon Dec 13, 2022
Related / duplicate: #85609