Eryk Sun added the comment:

Alternatively we could use the SleepEx and WaitFor*Ex functions with alertable 
waits (i.e. using APCs) instead of the SIGINT Event. This avoids having to 
replace all single-object waits with multiple-object waits, and would even 
allow calling SleepEx in pysleep. 

That said, issue 29871 proposes to switch to the condition variable and SRW 
lock implementation, so first it needs to be decided whether to continue to use 
kernel waits or switch to conditional variables. Or maybe refactor to use 
condition variables in performance-critical code and otherwise use kernel 
waits, if that makes sense.

An orthogonal improvement is to have the signal handler call 
CancelSynchronousIo. This would entail handling ERROR_OPERATION_ABORTED in 
_winapi Readfile, WriteFile, and WaitNamedPipe by calling PyErr_CheckSignals. 
Also in _Py_Read and _Py_Write, if errno is EINVAL and the last Windows error 
is ERROR_OPERATION_ABORTED, it could manually set errno to EINTR.

Winsock waits (e.g. select) will remain a problem in any case. Winsock uses 
alertable waits, so a queued user-mode APC will be executed while it's waiting. 
But then it just resumes its original wait instead of failing with WSAEINTR.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29971>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to