我的代码似乎挂在这个 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
代码在executeScriptOverSSH
方法上SshWorker
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
- 我已经通过使用 print 语句进行了检查。有任何想法吗?