subprocess.Popen все еще ждет при запуске Rserve
Локальная система: OSX 10.10.3 Yosemite Python 2.7
Удаленный сервер: NAME="Amazon Linux AMI" VERSION="2014.09"
Я пытаюсь использовать Python для запуска (перезапуска) процессов Rserve на сервере. Я могу запустить его как ec2-пользователь либо напрямую ($R CMD Rserve --vanilla), либо с помощью сценария SystemV ($service Rserve restart)... однако сценарий Python по-прежнему зависает в ожидании завершения запущенного процесса Rserve, Поскольку это демон, он не заканчивается и скрипт зависает.
Я пробовал как subprocess.call И подпроцесс 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...?)