Threading Keyboard Interrupt issue
On 5/29/19, David Raymond <David.Raymond at tomtom.com> wrote:
> Keyboard interrupts are only received by the main thread, which in this case
> completes real quick.
> So what happens for me is that the main thread runs to completion instantly
> and leaves nothing alive to receive the keyboard interrupt, which means the
> loop thread will run forever until killed externally. (Task manager,
> ctrl-break, etc)
The main thread is still running in order to join non-daemon threads.
In Windows, the internal wait used to join a thread can't be
interrupted by Ctrl+C, unlike POSIX platforms.
The Windows build could be modified to support Ctrl+C in this case,
but I'm only certain about the current build that uses emulated
When I run the OP's script in Linux, acquiring the internal
thread-state lock (which normally waits until the lock is reset when
the thread exits) gets interrupted by the SIGINT signal, and
KeyboardInterrupt is raised:
Exception ignored in: <module 'threading' from
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 1294, in _shutdown
File "/usr/lib/python3.6/threading.py", line 1056, in join
File "/usr/lib/python3.6/threading.py", line 1072, in
elif lock.acquire(block, timeout):