Commit 6021ddc9 authored by Chris Harris's avatar Chris Harris Committed by Code Review
Browse files

Merge topic 'vtkweb-launcher' into master

a53a88bb vtkWeb: Cleanup python processes that timeout on startup
3ce7a5ee vtkWeb: Use unbuffered file read/write for stdout
parents 958219ca a53a88bb
......@@ -291,7 +291,7 @@ class ProcessManager(object):
# Create output log file
logFilePath = self._getLogFilePath(session['id'])
with open(logFilePath, "a+") as log_file:
with open(logFilePath, "a+", 0) as log_file:
try:
proc = subprocess.Popen(session['cmd'], stdout=log_file, stderr=log_file)
self.processes[session['id']] = proc
......@@ -349,7 +349,7 @@ class ProcessManager(object):
# Check the output for ready_line
logFilePath = self._getLogFilePath(session['id'])
with open(logFilePath, "r") as log_file:
with open(logFilePath, "r", 0) as log_file:
for line in log_file.readlines():
if ready_line in line:
ready = True
......@@ -445,7 +445,8 @@ class LauncherResource(resource.Resource, object):
if not d:
d = defer.Deferred()
if not self.process_manager.isReady(session, count + 1):
if not 'startTimedOut' in session and \
not self.process_manager.isReady(session, count + 1):
reactor.callLater(1, self._waitForReady, session, request, count + 1, d)
else:
d.callback(request)
......@@ -465,6 +466,10 @@ class LauncherResource(resource.Resource, object):
request.setResponseCode(http.OK)
else:
request.write(json.dumps({"error": "Session did not start before timeout expired. Check session logs."}))
# Mark the session as timed out and clean up the process
session['startTimedOut'] = True
self.session_manager.deleteSession(session['id'])
self.process_manager.stopProcess(session['id'])
request.setResponseCode(http.SERVICE_UNAVAILABLE)
request.finish()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment