Skip to content

Commit

Permalink
Merge pull request #29 from SpiNNakerManchester/jenkins
Browse files Browse the repository at this point in the history
Jenkins
  • Loading branch information
rowleya committed Feb 15, 2019
2 parents 537dcff + 056fecb commit fac00cb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions spalloc/_keepalive_process.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
""" A script for keeping Spalloc jobs alive, intended to only ever be run\
from the Spalloc client itself.
"""
from __future__ import print_function
import sys
import threading
from spalloc.protocol_client import ProtocolClient, ProtocolTimeoutError
Expand Down Expand Up @@ -65,6 +66,8 @@ def keep_job_alive(hostname, port, job_id, keepalive_period, timeout,


if __name__ == "__main__":
print("KEEPALIVE")
sys.stdout.flush()
if len(sys.argv) != 7:
sys.stderr.write(
"wrong # args: should be '" + sys.argv[0] + " hostname port "
Expand Down
11 changes: 10 additions & 1 deletion spalloc/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,16 @@ def __init__(self, *args, **kwargs):
self._keepalive_process = subprocess.Popen(map(str, [
sys.executable, "-m", "spalloc._keepalive_process", hostname,
port, self.id, self._keepalive, self._timeout,
self._reconnect_delay]), stdin=subprocess.PIPE)
self._reconnect_delay]), stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
first_line = self._keepalive_process.stdout.readline().strip()
if first_line.startswith(b"pydev debugger"):
first_line = self._keepalive_process.stdout.readline().strip()
if len(first_line) == 0:
first_line = self._keepalive_process.stdout.readline().strip()
if first_line != b"KEEPALIVE":
raise Exception("Keepalive process wrote odd line: {}".format(
first_line))

def __enter__(self):
""" Convenience context manager for common case where a new job is to
Expand Down

0 comments on commit fac00cb

Please sign in to comment.