Python 2.7 启动Rserve时,subprocess.Popen仍在等待

Python 2.7 启动Rserve时,subprocess.Popen仍在等待,python-2.7,subprocess,popen,rserve,pyrserve,Python 2.7,Subprocess,Popen,Rserve,Pyrserve,本地系统: OSX 10.10.3约塞米蒂 Python 2.7 远程服务器: NAME=amazonlinuxami 版本=2014.09 我试图使用Python在服务器上重新启动Rserve进程。我可以作为ec2用户直接启动它$R CMD Rserve-vanilla,或者使用SystemV脚本$service Rserve restart…但是Python脚本仍然挂起,等待启动的Rserve进程完成。因为它是一个守护进程,所以它没有完成,脚本挂起 我尝试了subprocess.call和s

本地系统: OSX 10.10.3约塞米蒂 Python 2.7

远程服务器: NAME=amazonlinuxami 版本=2014.09

我试图使用Python在服务器上重新启动Rserve进程。我可以作为ec2用户直接启动它$R CMD Rserve-vanilla,或者使用SystemV脚本$service Rserve restart…但是Python脚本仍然挂起,等待启动的Rserve进程完成。因为它是一个守护进程,所以它没有完成,脚本挂起

我尝试了subprocess.call和subprocess Popen

log.error('Attempting to restart Rserve environment...')
PEM  = "/Users/xxx/ra.pem"
USER = "ec2-user"
PORT = '22'
SERVER = str(callobj.rhandler_host) # ends up confirmed correct IP
command = ['/sbin/service', 'Rserve', 'restart'] # Starts Rserve and hangs
# command = ['R', 'CMD', 'Rserve', '--vanilla'] # Starts Rserve and hangs
# command = ['ls'] # lists and finishes

ssh = ['ssh', '-i', PEM, '-p', PORT, USER + '@' + SERVER]
run = ssh + command

proc = subprocess.Popen(run, shell=False, 
#                         stdout=subprocess.PIPE) # Tried this, no change 
                          stdin=None, stdout=None, stderr=None, close_fds=True)
输出:

2015-06-06 16:51:51,362 - MRATrefactor - ERROR - [R] environment does not appear to be running on server '54.xxx.xxx.x2'. Connection denied, server not reachable or not accepting connections
2015-06-06 16:51:51,363 - MRATrefactor - ERROR - rserveHandler.connect: ; *args: None; **kwargs: None; RserveNotRunning: [R] environment does not appear to be running on server '54.xxx.xxx.x2'. Connection denied, server not reachable or not accepting connections. Rserve may not be running.
2015-06-06 16:51:51,363 - MRATrefactor - ERROR - Attempting to restart Rserve environment...
    PID: 8205
    Cannot match 8205 to running processes.
    Grepping for process [expecting PID: 8205]...

    grep count: 0
    0
    Stopping Rserve:  [FAILED]
    Starting Rserve: 
    R version 3.1.1 (2014-07-10) -- "Sock it to Me"
    Copyright (C) 2014 The R Foundation for Statistical Computing
    Platform: x86_64-redhat-linux-gnu (64-bit)

    R is free software and comes with ABSOLUTELY NO WARRANTY.
    You are welcome to redistribute it under certain conditions.
    Type 'license()' or 'licence()' for distribution details.

    Natural language support but running in an English locale

    R is a collaborative project with many contributors.
    Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications.

    Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help.
    Type 'q()' to quit R.

    Rserv started in daemon mode.
    ec2-user 8385 1 0 14:51 ? 00:00:00 /usr/lib64/R/bin/Rserve --vanilla
    PID: 8385
    Starting Rserve:  [  OK  ]

(and script hangs here...apparently (maybe) waiting...?)

Popen应该适用于这个用例;我们一定要看看你的密码。我的系统在写信息时冻结了:我必须在别人看到它之前重新启动:DP.s。如果我将命令从Rserve更改为,例如“ls”…它确实有效。所以我不确定这是一个Rserve问题还是Popen问题,因为ls当然会结束。