Commit 956d74ee authored by Antoine Catton's avatar Antoine Catton

Implementation of timeout for promise checking

parent 938baf9e
......@@ -35,6 +35,7 @@ if sys.version_info < (2, 6):
import socket
import subprocess
import traceback
import time
#from time import strftime
from SlapObject import Software, Partition, WrongPermissionError, \
......@@ -559,17 +560,18 @@ class Slapgrid(object):
if not self.console:
kw.update(stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
# TODO-Antoine: Implement a timeout on promise script execution
process_handler = SlapPopen(invocation_list,
preexec_fn=lambda: dropPrivileges(uid, gid),
cwd=instance_path,
env=None, **kw)
stderr = process_handler.communicate()[1]
time.sleep(3) # 3 seconds timeout
if process_handler.returncode is None:
process_handler.kill()
computer_partition.error("The promise '%s' timed out" % promise)
if process_handler.returncode != 0:
elif process_handler.returncode != 0:
stderr = process_handler.communicate()[1]
if stderr is None:
stderr = 'No error output from %s.' % promise
computer_partition.error(stderr)
......
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