Skip to content

Commit

Permalink
response to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
andre-merzky committed May 7, 2024
1 parent 0ead245 commit 4c47c78
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
1 change: 0 additions & 1 deletion requirements-ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# RU from the current branch
.

requests
pytest
pytest-timeout
pylint
Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

''' Setup script, only usable via pip. '''

import re
import os

import subprocess as sp
Expand Down Expand Up @@ -84,7 +83,7 @@ def get_version(_mod_root):

_version_tag = _out

_out, _, _ret = sh_callout('cd %s && git branch --show-current' % root)
_out, _err, _ret = sh_callout('cd %s && git branch --show-current' % root)
assert _ret == 0, 'git branch failed'

_out = _out.decode()
Expand Down Expand Up @@ -194,7 +193,7 @@ def run(self):
# ------------------------------------------------------------------------------
# clean temporary files from source tree
os.system('rm -vrf src/%s.egg-info' % name)
os.system('rm -vf %s/VERSION' % version_path)
os.system('rm -vf %s' % version_path)


# ------------------------------------------------------------------------------
Expand Down
30 changes: 15 additions & 15 deletions src/radical/utils/heartbeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ def __init__(self, uid, timeout, interval=1, beat_cb=None, term_cb=None,
if not self._log:
self._log = Logger('radical.utils.heartbeat')

self._log.debug('hb %s create', self._uid)
self._log.debug_1('hb %s create', self._uid)


# --------------------------------------------------------------------------
#
def start(self):

self._log.debug('hb %s start', self._uid)
self._log.debug_1('hb %s start', self._uid)
self._watcher = mt.Thread(target=self._watch)
self._watcher.daemon = True
self._watcher.start()
Expand Down Expand Up @@ -100,7 +100,7 @@ def dump(self, log):

if not log: log = self._log

log.debug('hb dump %s: \n%s', self._uid, pprint.pformat(self._tstamps))
log.debug_9('hb dump %s: \n%s', self._uid, pprint.pformat(self._tstamps))


# --------------------------------------------------------------------------
Expand All @@ -109,7 +109,7 @@ def watch(self, uid):

with self._lock:
if uid not in self._tstamps:
self._log.debug('hb %s watch %s', self._uid, uid)
self._log.debug_8('hb %s watch %s', self._uid, uid)
self._tstamps[uid] = None


Expand All @@ -119,28 +119,28 @@ def _watch(self):

# initial heartbeat without delay
if self._beat_cb:
self._log.debug('hb %s beat cb init', self._uid)
self._log.debug_8('hb %s beat cb init', self._uid)
self._beat_cb()

while not self._term.is_set():

self._log.debug('hb %s loop %s', self._uid, self._interval)
self._log.debug_8('hb %s loop %s', self._uid, self._interval)

time.sleep(self._interval)
now = time.time()

if self._beat_cb:
self._log.debug('hb %s beat cb', self._uid)
self._log.debug_8('hb %s beat cb', self._uid)
self._beat_cb()

# avoid iteration over changing dict
with self._lock:
uids = list(self._tstamps.keys())

self._log.debug('hb %s uids %s', self._uid, uids)
self._log.debug_8('hb %s uids %s', self._uid, uids)
for uid in uids:

self._log.debug('hb %s check %s', self._uid, uid)
self._log.debug_8('hb %s check %s', self._uid, uid)

with self._lock:
last = self._tstamps.get(uid)
Expand Down Expand Up @@ -180,8 +180,8 @@ def _watch(self):
# heartbeat for the new one, so that we can immediately
# begin to watch it.
assert isinstance(ret, str)
self._log.info('hb %s recov %s -> %s (%s)',
self._uid, uid, ret, self._term_cb)
self._log.info_1('hb %s recov %s -> %s (%s)',
self._uid, uid, ret, self._term_cb)
with self._lock:
del self._tstamps[uid]
self._tstamps[ret] = time.time()
Expand All @@ -198,7 +198,7 @@ def beat(self, uid=None, timestamp=None):
uid = 'default'

with self._lock:
self._log.debug('hb %s beat [%s]', self._uid, uid)
self._log.debug_9('hb %s beat [%s]', self._uid, uid)
self._tstamps[uid] = timestamp


Expand Down Expand Up @@ -242,14 +242,14 @@ def wait_startup(self, uids=None, timeout=None):
ok = [uid for uid in uids if self._tstamps.get(uid)]
nok = [uid for uid in uids if uid not in ok]

self._log.debug('wait for : %s', nok)
self._log.debug_3('wait for : %s', nok)

if len(ok) == len(uids):
break

if timeout:
if time.time() - start > timeout:
self._log.debug('wait time: %s', nok)
self._log.debug_3('wait time: %s', nok)
break

time.sleep(0.25)
Expand All @@ -260,7 +260,7 @@ def wait_startup(self, uids=None, timeout=None):
return nok

else:
self._log.debug('wait ok : %s', ok)
self._log.debug_3('wait ok : %s', ok)


# ------------------------------------------------------------------------------
Expand Down

0 comments on commit 4c47c78

Please sign in to comment.