【发布时间】:2012-10-02 20:37:48
【问题描述】:
我的代码似乎挂在这个 popen 调用上
command = "ls"
commandList = shlex.split(command)
print("Executing " + command +"\n")
print(commandList)
output = "#" * 10 + "\n" + server.name + "\n\n"
process = subprocess.Popen(
command,
shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
output = process.communicate()[0]
#scriptRunner.threadComplete(output)
return output
代码在SshWorker上的executeScriptOverSSH方法中
class WorkerThread(threading.Thread):
def __init__(self, pathToScript, server, runner):
super(WorkerThread, self).__init__()
self.scriptRunner = runner
self.server = server
self.pathToScript = pathToScript
self.sshWorker = SshWorker.SshWorker()
def run(self):
print('Thread Starting')
output = self.sshWorker.executeScriptOverSSH(
self.server,
self.pathToScript)
print('Thread Finishing!')
self.scriptRunner.threadComplete(output)`
线程永远不会超过对Popen 的调用——我已经在那里使用打印语句进行了检查。有什么想法吗?
【问题讨论】:
标签: python multithreading popen