有时会引发错误的文件描述符错误,有时不会

时间:2019-09-23 00:34:57

标签: python-3.x bash shell process

下面的代码可以正常工作一年,最近它间歇性地由于以下错误而开始失败,想知道是否有任何操作系统或硬件更改导致了此问题

import subprocess
def bash_command(cmd):
    process = subprocess.Popen(cmd, shell=True, executable="/bin/bash")
    process.wait()

bash_command("bash myscript.sh")

错误消息是:

Traceback (most recent call last):   File
"/Users/ishandutta2007/Documents/Projects/p2/shell_way/all_in_one_refill.py",
line 68,
    bash myscript.sh   File "/Users/ishandutta2007/Documents/Projects/p2/shell_way/all_in_one_refill.py",
line 31, in bash_command
    process = subprocess.Popen(cmd, shell=True, executable="/bin/bash")   File
"/Users/ishandutta2007/.pyenv/versions/3.6.0/lib/python3.6/subprocess.py",
line 707, in __init__
    restore_signals, start_new_session)   File "/Users/ishandutta2007/.pyenv/versions/3.6.0/lib/python3.6/subprocess.py",
line 1326, in _execute_child
    raise child_exception_type(errno_num, err_msg) OSError: [Errno 9] Bad file descriptor

0 个答案:

没有答案