KeyboardInterrupt traceback using subprocess

Viewed 34

I am getting KeyboardInterrupt Traceback using the subprocess code. (No CTRL+C from stdin)

Code

def get_cmd_output(command):
        output = subprocess.check_output(command,shell=True,stderr=subprocess.STDOUT,preexec_fn=lambda:signal.signal(signal.SIGPIPE, signal.SIG_DFL),timeout=600)
        output = output.decode("utf-8")
        output = output.strip().split('\n')
        return output
get_cmd_output("grep -Ff a.txt b.txt > c.txt")

Error

Traceback (most recent call last):
  File "abc.py", line 13, in get_cmd_output
    output = subprocess.check_output(command,shell=True,stderr=subprocess.STDOUT,preexec_fn=lambda:signal.signal(signal.SIGPIPE, signal.SIG_DFL),timeout=600)
  File "/usr/lib64/python3.4/subprocess.py", line 606, in check_output
    output, unused_err = process.communicate(inputdata, timeout=timeout)
  File "/usr/lib64/python3.4/subprocess.py", line 959, in communicate
    stdout, stderr = self._communicate(input, endtime, timeout)
  File "/usr/lib64/python3.4/subprocess.py", line 1624, in _communicate
    ready = selector.select(timeout)
  File "/usr/lib64/python3.4/selectors.py", line 367, in select
    fd_event_list = self._poll.poll(timeout)
KeyboardInterrupt

Need help in handling this traceback!

0 Answers
Related