Python Subprocess.check_输出或xclip-o挂起

Python Subprocess.check_输出或xclip-o挂起,python,xclip,Python,Xclip,在Linux mint上,我使用以下代码监视剪贴板: last_clip = '' try: while True: clip_contents = subprocess.check_output(['xclip', '-o']) if clip_contents != last_clip: #write clip_contents to file time.sleep(0.5) except KeyboardInte

在Linux mint上,我使用以下代码监视剪贴板:

last_clip = ''
try:
    while True:
        clip_contents = subprocess.check_output(['xclip', '-o'])
        if clip_contents != last_clip:
           #write clip_contents to file
        time.sleep(0.5)
except KeyboardInterrupt:
    print(" Quitting...")
它工作得很好,只是偶尔会挂断。我相当确定它在
check\u output
行,因为
ps aux
显示
xclip-o
是一个活动的进程。当我用
-INT
-HUP
杀死它时,我得到了这个回溯:

Traceback (most recent call last):
  File "get.py", line 16, in <module>
    clip_contents = subprocess.check_output(['xclip', '-o'])
  File "/usr/lib/python2.7/subprocess.py", line 544, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['xclip', '-o']' returned non-zero exit status -1
回溯(最近一次呼叫最后一次):
文件“get.py”,第16行,在
clip_contents=子进程。检查_输出(['xclip','-o'])
文件“/usr/lib/python2.7/subprocess.py”,第544行,在check_输出中
引发被调用的进程错误(retcode,cmd,output=output)
subprocess.CalledProcessError:命令“['xclip','-o']”返回非零退出状态-1
我是做错了什么事,还是这里出了什么事