有时通过python子进程挂起调用Java命令

时间:2015-04-21 02:59:38

标签: java python subprocess hang

我在各种机器上使用python 2.7.0 -2.7.7并遇到了同样的问题。

我们有python程序从工具中调用一些java命令来读取数据 核心转储。 在正常情况下,代码运行良好,但如果核心转储很大,那么当python程序执行以下命令时,我们会遇到挂起问题: java -classpath toolview.jar:tool.jar -Dcom.ibm.java.diagnostics.plugins = toolcommands.jar com.java.diagnostics.tool.launcher.TOOLViewLauncher -core badleakcore.56130 command1

有关如何调试此方法或解决方法的任何建议吗?提前致谢。 如果我们在命令行上运行完全相同的命令,它将工作,但它也 由于大型核心转储需要很长时间。

This is the snippet of python code how we invoke java:

import logging, sys, argparse, time, platform
from subprocess import Popen, PIPE, STDOUT

 def runTests(core, logger):
failure = []

 #command1
 msgs = ["Command: command1", "Expected: Pass without exceptions"]
 logHeader(msgs, logger)
 retlist = executeTOOL(core, "command1", logger, failure)




def executeIDDE(core, args, logger, failureList):
if platform.system().lower() == "windows":
    sep = ";"
else:
    sep = ":"

cp = 'toolview.jar'+sep+'tool.jar'  
    cmds = 'toolcommands.jar'
plugin = '-Dcom.ibm.java.diagnostics.plugins'
main = 'com.java.diagnostics.view.launcher.TOOLViewLauncher'
cmd = 'java -classpath ' + cp + ' ' + plugin + '=' + cmds + ' '
    +    main    + '  -core ' + core + ' ' + args
    print(cmd)
proc = Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True)

0 个答案:

没有答案
相关问题