BrianGallew / cassandra_range_repair

python script to repair the primary range of a node in N discrete steps
MIT License
109 stars 47 forks source link

feature request: Handle control-c (KeyboardInterrupt) gracefully #19

Open shawnbutts opened 9 years ago

shawnbutts commented 9 years ago

Currently, when hitting control-c to stop the script the following error is printed.

Process PoolWorker-1: Traceback (most recent call last): File "/usr/lib64/python2.6/multiprocessing/process.py", line 232, in _bootstrap self.run() File "/usr/lib64/python2.6/multiprocessing/process.py", line 88, in run self._target(_self._args, _self._kwargs) File "/usr/lib64/python2.6/multiprocessing/pool.py", line 68, in worker result = (True, func(_args, _kwds)) File "/root/bin/range_repair.py", line 221, in repairrange success, cmd, , stderr = run_command(*cmd) File "/root/bin/range_repair.py", line 194, in run_command stdout, stderr = proc.communicate() File "/usr/lib64/python2.6/subprocess.py", line 732, in communicate stdout, stderr = self._communicate(input, endtime) File "/usr/lib64/python2.6/subprocess.py", line 1316, in _communicate stdout, stderr = self._communicate_with_poll(input, endtime) File "/usr/lib64/python2.6/subprocess.py", line 1388, in _communicate_with_poll ready = poller.poll(self._remaining_time(endtime)) KeyboardInterrupt

The process then hangs until the pid is killed from a different session.

BrianGallew commented 9 years ago

FTR? I kind of hate multiprocessing.