0

Eclipse/PyDev 内で python スクリプトをデバッグしようとしていますが、開発環境内から実行するとスクリプトが正しく実行されないようです。

Eclipse/PyDev 環境では、デバッグ中のプログラムのコマンド ライン ツールへのアクセスが制限されているようです。

この制限を回避するにはどうすればよいですか? おそらく、Eclipse プロジェクトに関連するコマンド ライン ツールへの参照を追加する方法はありますか?

更新日:

これは、外部アプリを実行しようとするコードのチャンクです。問題はそこにある子スレッドに関連している可能性がありますか?

def call_command_in_dir_unix(app, args, targetdir):
    # this is the unix implementation
    (r,w) = os.pipe()
    pid = os.fork()
    if pid == -1:
      return 'could not fork'
    if pid == 0:
      # child
      print "child!"
      os.close(r)
      os.dup2(os.open("/dev/null", os.O_WRONLY), 0)
      os.dup2(w, 1)
      os.dup2(w, 2)
      os.chdir(targetdir)
      os.environ['openin_any'] = 'p'
      os.environ['openout_any'] = 'p'
      os.environ['shell_escape'] = 'f'
      import resource
      resource.setrlimit(resource.RLIMIT_CPU,
                         (MAX_RUN_TIME * 1000, MAX_RUN_TIME * 1000)) # docs say this is seconds, but it is msecs on my system.
      # os.execvp will raise an exception if the executable isn't
      # present. [[ try os.execvp("aoeu", ['aoeu'])  ]]
      # If we don't catch exceptions here, it will be caught at the
      # main body below, and then os.rmdir(tmpdir) will be called
      # twice, once for each fork.  The second one raises an exception
      # in the main code, which gets back to the user.  This is bad.
      try:
        os.execvp(app, [app] + list(args))
      finally:
        print "failed to exec()",app
        os._exit(2)
    else:
      # parent
      os.close(w)
      r = os.fdopen(r,"r")
      output = ''.join(r.readlines())
      (npid, exi) = os.waitpid(pid, 0)
      r.close()
      sig = exi & 0xFF
      stat = exi >> 8
      if stat != 0 or sig != 0:
        return ' error! exitcode was %d (signal %d), transscript follows:\n\n%s' % (stat,sig,output)
      return None
    # notreached      
4

0 に答える 0