classification
Title: Ctrl+C Can't Exit Script with Pool on Windows
Type: behavior Stage:
Components: Windows Versions: Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Meng-Yuan Huang, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2015-12-28 07:48 by Meng-Yuan Huang, last changed 2015-12-28 07:48 by Meng-Yuan Huang.

Files
File name Uploaded Description Edit
t.py Meng-Yuan Huang, 2015-12-28 07:48 A Script Using multiprocessing.Pool
Messages (1)
msg257106 - (view) Author: Meng-Yuan Huang (Meng-Yuan Huang) Date: 2015-12-28 07:48
My OS is Windows 10 Pro 64-bit. My Python version is 3.5.1 64-bit.
I wrote a simple script (t.py, see the attached file) with multiprocessing.Pool and run it by:
python t.py
in Windows Command Prompt.
I tried to interrupt the running script by pressing Ctrl+C keys. Python showed the message:
-----------------------------------
Work Started: 21360
Process SpawnPoolWorker-1:
Traceback (most recent call last):
  File "d:\Anaconda3\lib\multiprocessing\process.py", line 254, in _bootstrap
    self.run()
  File "d:\Anaconda3\lib\multiprocessing\process.py", line 93, in run
    self._target(*self._args, **self._kwargs)
  File "d:\Anaconda3\lib\multiprocessing\pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "C:\Users\myh\Documents\Python Scripts\t.py", line 7, in do_work
    1
KeyboardInterrupt
-----------------------------------

However, it didn't terminate Python and come back to Windows Command Prompt. It just hang there.
Then, I pressed another Ctrl+C. Python showed:
-----------------------------------
Process SpawnPoolWorker-2:
Traceback (most recent call last):
  File "d:\Anaconda3\lib\multiprocessing\process.py", line 254, in _bootstrap
    self.run()
  File "d:\Anaconda3\lib\multiprocessing\process.py", line 93, in run
    self._target(*self._args, **self._kwargs)
  File "d:\Anaconda3\lib\multiprocessing\pool.py", line 108, in worker
    task = get()
  File "d:\Anaconda3\lib\multiprocessing\queues.py", line 343, in get
    res = self._reader.recv_bytes()
  File "d:\Anaconda3\lib\multiprocessing\connection.py", line 216, in recv_bytes
    buf = self._recv_bytes(maxlength)
  File "d:\Anaconda3\lib\multiprocessing\connection.py", line 306, in _recv_bytes
    [ov.event], False, INFINITE)
KeyboardInterrupt
-----------------------------------

Unfortunately, it still didn't terminate Python and come back to Windows Command Prompt!
However, I run the same script with Python 3.5.1 64-bit on a CetnOS 7 64-bit,
it can terminate Python and come back to the terminal.

Is this a bug on Windows?
History
Date User Action Args
2015-12-28 07:48:19Meng-Yuan Huangcreate