Eryk Sun added the comment:
Alexander, I wrote the above sample function to be slotted directly into the
existing design based on the SIGINT event. I wasn't looking to rewrite
everything using user-mode APCs and alertable waits. A change like that could
have ramifications for applications th
Alexander Grigoriev added the comment:
@ericsun:
Windows calls the console event handler in a separate thread. The console event
handler receives CTRL_C_EVENT, CTRL_BREAK_EVENT, console close, logoff, system
shutdown events.
Originally, Windows devised an APC mechanism to simulate asynchron
Eryk Sun added the comment:
> But on this particular issue, making the unconditional wait be
> interruptable by signals shouldn't be impossible.
PyThread_acquire_lock_timed() in Python/thread_nt.h currently ignores
intr_flag. The current implementation calls EnterNonRecursiveMutex(), which i
Steve Dower added the comment:
I'm not sure it's quite as simple as calling sys.exit, but it would be a great
project to bring universal cancellation support to all (regularly) blocking
functions. Asyncio has suffered from this as well.
Part of the problem is that POSIX APIs often don't supp
Eryk Sun added the comment:
Python's C signal handler sets a flag and returns, and the signal is eventually
handled in the main thread. In Windows, this means the Python SIGINT handler
won't be called so long as the main thread is blocked. (In Unix the signal is
delivered on the main thread
Chris Billington added the comment:
If I add:
import signal
signal.signal(signal.SIGINT, signal.SIG_DFL)
before the wait() call, then the call is interruptible on both Python versions
without needing to add a timeout.
--
___
Python tracker
New submission from Chris Billington :
I'm experiencing that the following short program:
import threading
event = threading.Event()
event.wait()
Cannot be interrupted with Ctrl-C on Python 2.7.15 or 3.7.1 on Windows 10
(using the Anaconda Python distribution).
However, if the wait is given