Skip to content

Commit

Permalink
Improve is_active lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
frthjf committed May 24, 2024
1 parent 299ea20 commit a30841c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/machinable/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,14 +411,18 @@ def is_active(
):
"""True if not finished and last heartbeat occurred less than 30 seconds ago"""
executable = self.executable(executable)
if not self.heartbeat_at(
executable,

if self.is_finished(executable):
return False

if not (
heartbeat := self.heartbeat_at(
executable,
)
):
return False

return (not self.is_finished(executable)) and (
(arrow.now() - self.heartbeat_at(executable)).seconds < 30
)
return (arrow.now() - heartbeat).seconds < 30

def is_live(
self,
Expand Down

0 comments on commit a30841c

Please sign in to comment.