簡體   English   中英

Python Popen,管道破裂錯誤

[英]Python Popen, broken pipe erro


目前,我正在使用libsvm,並帶有一個用Python編寫的庫(easy.py和grid.py [1])。 我有“ [[Errono32]:斷管”。 我不了解python,但經過一段時間的錯誤搜索后,我知道它來自讀取/寫入文件。 因此,我在這里復制了所有的I / O文件訪問代碼,但我不知道其中哪個會導致此問題。希望您能為我提供幫助。

分數1:

class LocalWorker(Worker):
    def run_one(self,c,g):
        cmdline = self.get_cmd(c,g)
        result = Popen(cmdline,shell=True,stdout=PIPE,stderr=PIPE,stdin=PIPE).stdout
        for line in result.readlines():
            if str(line).find('Cross') != -1:
                return float(line.split()[-1][0:-1])

分數2:

class SSHWorker(Worker):
    def __init__(self,name,job_queue,result_queue,host,options):
        Worker.__init__(self,name,job_queue,result_queue,options)
        self.host = host
        self.cwd = os.getcwd()
    def run_one(self,c,g):
        cmdline = 'ssh -x -t -t {0} "cd {1}; {2}"'.format\
            (self.host,self.cwd,self.get_cmd(c,g))
        result = Popen(cmdline,shell=True,stdout=PIPE,stderr=PIPE,stdin=PIPE).stdout
        for line in result.readlines():
            if str(line).find('Cross') != -1:
                return float(line.split()[-1][0:-1])

分數3:

if options.gnuplot_pathname:
    gnuplot = Popen(options.gnuplot_pathname,stdin = PIPE,stdout=PIPE,stderr=PIPE).stdin
else:
    gnuplot = None

我使用的是Mac OS 10.9,Python 2.7.5,我有兩台計算機,在相同的macOS和python版本上運行,但是一台可以正常運行而不會出現錯誤,一台運行時會出現管道破裂錯誤。
如果您有任何建議,請告訴我。 非常感謝你。

管道破裂是為了嘗試寫入封閉的管道。 顯然,您僅寫入gnuplot。 看起來在您的系統gnuplot之一上無法啟動。 根據可用的信息,我無濟於事。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM