aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek.chauhan@gmail.com>2008-07-04 19:06:59 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2008-07-04 19:06:59 +0530
commitba59d9b26ccb62e8aefcc3549a7bf96754c7fa0c (patch)
tree4c8f1e8f7bb6110abb37a3039a03708cc1689597 /slave/autotua
parent- Move running of commands to autotua.daemon (diff)
downloadautotua-ba59d9b26ccb62e8aefcc3549a7bf96754c7fa0c.tar.gz
autotua-ba59d9b26ccb62e8aefcc3549a7bf96754c7fa0c.tar.bz2
autotua-ba59d9b26ccb62e8aefcc3549a7bf96754c7fa0c.zip
Move jobuild.sh 'ping-pong' code to autotua.daemon
Diffstat (limited to 'slave/autotua')
-rw-r--r--slave/autotua/daemon/__init__.py11
-rw-r--r--slave/autotua/jobuild/__init__.py5
2 files changed, 10 insertions, 6 deletions
diff --git a/slave/autotua/daemon/__init__.py b/slave/autotua/daemon/__init__.py
index c83cafd..52b971a 100644
--- a/slave/autotua/daemon/__init__.py
+++ b/slave/autotua/daemon/__init__.py
@@ -10,7 +10,11 @@ import subprocess
from .. import const
class Spawn(object):
- """Spawn a daemonized sub-process in a shell"""
+ """
+ Spawn a daemonized sub-process in a shell
+ The sub-process must respond to the 'ping\n'
+ sent to stdin with a 'pong\n'
+ """
def __init__(self, command, logfile=const.LOGFILE):
"""
@@ -24,3 +28,8 @@ class Spawn(object):
# stdout goes to self.logfile
self.command = '%s 3>&2 2>&1 | tee -a \"%s\"' % (command, self.logfile)
self.process = subprocess.Popen(self.command, shell=True, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
+ self.process.stdin.write('ping\n')
+ response = self.process.stderr.readline()
+ if not response == 'pong\n':
+ # FIXME: Custom exceptions
+ raise 'Communication error: received %s when expecting "pong"' % response
diff --git a/slave/autotua/jobuild/__init__.py b/slave/autotua/jobuild/__init__.py
index 6831b11..878b573 100644
--- a/slave/autotua/jobuild/__init__.py
+++ b/slave/autotua/jobuild/__init__.py
@@ -124,10 +124,5 @@ class Processor(object):
def _msg(self, msg):
proc = daemon.Spawn('\"%s\"/bin/jobuild.sh %s' % (const.AUTOTUA_DIR, msg))
- proc.process.stdin.write('ping\n')
- response = proc.process.stderr.readline()[:-1] # Remove trailing newline
- if not response == 'pong':
- # FIXME: Custom exceptions
- raise 'Communication error: received %s when expecting "pong"' % response
response = proc.process.stderr.read()[:-1] # Remove trailing newline
return response