summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/server/singleton_daemon.py
diff options
context:
space:
mode:
authorYaroslav Brustinov <ybrustin@cisco.com>2016-06-06 11:10:44 +0300
committerYaroslav Brustinov <ybrustin@cisco.com>2016-06-06 11:10:44 +0300
commit1454985e5408bdf796a9c9978622f2ba66ec04d8 (patch)
tree6319682d51fcf6756c3166491337ac0c85b149f6 /scripts/automation/trex_control_plane/server/singleton_daemon.py
parent2aaf83ee88b49e3a10543f8415f73652be606ecc (diff)
daemons fixes
Diffstat (limited to 'scripts/automation/trex_control_plane/server/singleton_daemon.py')
-rwxr-xr-xscripts/automation/trex_control_plane/server/singleton_daemon.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/scripts/automation/trex_control_plane/server/singleton_daemon.py b/scripts/automation/trex_control_plane/server/singleton_daemon.py
index 81b384c5..8fdedc6e 100755
--- a/scripts/automation/trex_control_plane/server/singleton_daemon.py
+++ b/scripts/automation/trex_control_plane/server/singleton_daemon.py
@@ -11,7 +11,7 @@ import jsonrpclib
# uses Unix sockets for determine running process.
# (assumes used daemons will register proper socket)
-# all daemons should use -p argument as listening tcp port
+# all daemons should use -p argument as listening tcp port and check_connectivity RPC method
class SingletonDaemon(object):
# run_cmd can be function of how to run daemon or a str to run at subprocess
@@ -102,15 +102,10 @@ class SingletonDaemon(object):
poll_rate = 0.1
for i in range(int(timeout/poll_rate)):
try:
- daemon.not_existing_function_asdfasd()
+ daemon.check_connectivity()
+ return True
except socket.error: # daemon is not up yet
sleep(poll_rate)
- except Exception as e: # expect error of not supported function
- if type(e.args) is tuple and\
- type(e.args[0]) is tuple and\
- e.args[0][0] == -32601: # error code is written hardcoded in JsonRPC Server
- return True
- raise
return False
# start daemon
@@ -175,6 +170,8 @@ def run_command(command, timeout = 15, cwd = None):
if proc.poll() is None:
proc.kill() # timeout
return (errno.ETIME, '', 'Timeout on running: %s' % command)
+ else:
+ proc.wait()
stdout_file.seek(0)
stderr_file.seek(0)
return (proc.returncode, stdout_file.read().decode(errors = 'replace'), stderr_file.read().decode(errors = 'replace'))