提交 195d65d4 编写于 作者: J Jimmy Yih

Fix gpsegwalrep.py deadlock issue

When running `gpsegwalrep.py start`, it would intermittently deadlock
on the subprocess.check_output call.  Apparently, concurrent
subprocess.check_output calls can deadlock depending on what shell
commands are run and how fast they execute.  For now, fix the issue by
only calling subprocess.check_output under a thread lock.  Someone can
revisit this later although it is assumed a proper tool will be
created in the near future.
上级 41ba1012
......@@ -33,6 +33,7 @@ import threading
from gppylib.db import dbconn
PRINT_LOCK = threading.Lock()
THREAD_LOCK = threading.Lock()
def runcommands(commands, thread_name, command_finish, exit_on_error=True):
output = []
......@@ -40,7 +41,8 @@ def runcommands(commands, thread_name, command_finish, exit_on_error=True):
for command in commands:
try:
output.append('Running command... %s' % command)
output = output + subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True).split('\n')
with THREAD_LOCK:
output = output + subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True).split('\n')
except subprocess.CalledProcessError, e:
output.append(str(e))
if exit_on_error:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册