Skip to content

Commit

Permalink
Merge pull request #128 from kube-HPC/bug_wrapper_algorunner_out_of_m…
Browse files Browse the repository at this point in the history
…emory

Bug wrapper algorunner out of memory
  • Loading branch information
Adir111 authored Aug 21, 2024
2 parents e083925 + 18a673a commit bbf7243
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions hkube_python_wrapper/wrapper/algorunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def __init__(self):
self._stopped = False
self._redirectLogs = False
self._printThread = 0
self._done = True
DaemonThread.__init__(self, "WorkerListener")

@staticmethod
Expand Down Expand Up @@ -316,6 +317,16 @@ def _getMethod(self, name):
return self._algorithm.get(name)
return None

def _aliveSignal(self):
def routine():
while not self._done and not self.stopped:
self._sendCommand(messages.outgoing.alive, None)
print("stopped is: ", self._stopped)
time.sleep(5)

thread = threading.Thread(target=routine)
thread.start()

def _init(self, options):
redirector = None
try:
Expand All @@ -335,6 +346,8 @@ def _init(self, options):
if (method is not None):
method(options)
self._sendCommand(messages.outgoing.initialized, None)
self._done = False
self._aliveSignal()

except Exception as e:
self.sendError(e)
Expand Down Expand Up @@ -404,6 +417,7 @@ def _start(self, options):
method(self._input)
method = self._getMethod('start')
algorithmData = method(self._input, self._hkubeApi)
self._done = True
if not (self._stopped):
self._handle_response(algorithmData, jobId, taskId, nodeName, savePaths, span)

Expand Down
1 change: 1 addition & 0 deletions hkube_python_wrapper/wrapper/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def __init__(self):
self.streamingOutMessage = "streamingOutMessage"
self.streamingInMessageDone = "streamingInMessageDone"
self.logData = "logData"
self.alive = "alive"


class Incoming(object):
Expand Down

0 comments on commit bbf7243

Please sign in to comment.