2

lsf ファームで ( を使用して"qsub -I") 実行する必要があるコマンドのリストがあります。コマンドがcommands_lにリストされているとしましょう。一度に2つのプロセスを実行しようとしているマルチプロセッシングモジュールを使用しています。(私はLinuxを使用しています)

コードは次のとおりです。

import subprocess, multiprocessing
import os,sys,os.path

def execCmd(cmd):
  """ Executes the command """
  print "Executing:",cmd
  ret = subprocess.call(cmd,shell=True)
  return ret

if __name__=="__main__":
  commands_l = ['qsub -P test -I ls -l', 'qsub -P test -I df -kh', 'qsub -P test -I du -kh .']

  results_l = []
  errorcodes_l = []
  max_proc = 2
  pool = multiprocessing.Pool(processes=max_proc)
  for command in commands_l:
    print "# %s" % (command)
    errorcode = pool.apply_async(execCmd, (command,), callback=results_l.append)
    errorcodes_l.append(errorcode)
  pool.close()
  pool.join()
  print "Results:", results_l
  sys.exit(0)

私が直面している問題は、実行が出力で動かなくなることです:

# qsub -P test -I ls -l
# qsub -P test -I df -kh
# qsub -P test -I du -kh .
Executing: qsub -P test -I ls -l
Executing: qsub -P test -I df -kh
Job <1683534> is submitted to queue <q_interactive>.
<<Waiting for dispatch ...>>
Job <1683535> is submitted to queue <q_interactive>.
<<Waiting for dispatch ...>>
<<Starting on machine-23>>
<<Starting on machine-20>>

奇妙なことに、同じコマンド「qsub -P test -I ls -l」で execCmd を単独で実行すると、正常に動作します。

>>> import multiprocess_qsub # my py file that contains the abovementioned code
>>> multiprocess_qsub.execCmd("qsub -P test -I ls -l")
Executing: qsub -P test -I ls -l
Job <1687635> is submitted to queue <q_interactive>.
<<Waiting for dispatch ...>>
<<Starting on machine-02>>
total 3
-rwx------  1 tully user 2959 Jul  5 14:54 functions.py
-rwx------  1 tully user 906  Jun 27 23:06 gui.py
-rw-------  1 tully user 1684 Jul 13 14:24 multiprocess_qsub.py

qsub は、マルチプロセッシング環境内からの実行に問題があるように思えます。何か不足していますか?ありがとう。

4

0 に答える 0