Skip to content

Commit

Permalink
CTX-6357: Sending heartbeats while uploading artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
Dusko Vesic committed Sep 6, 2024
1 parent c033592 commit 7bdc793
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions coretex/_task/worker/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ def track(taskRun: TaskRun) -> Iterator[FileEventHandler]:
observer.stop() # type: ignore[no-untyped-call]
observer.join()

logging.getLogger("coretexpylib").debug(">> [Coretex] Heartbeat")
taskRun.updateStatus() # updateStatus without params is considered heartbeat
lastTimeHeartbeat = timeit.default_timer()

for index, artifactPath in enumerate(eventHandler.artifactPaths):
logging.getLogger("coretexpylib").debug(f">> [Coretex] Uploading {index + 1}/{len(eventHandler.artifactPaths)} - \"{artifactPath}\"")

Expand All @@ -95,3 +99,8 @@ def track(taskRun: TaskRun) -> Iterator[FileEventHandler]:
except Exception as e:
logging.getLogger("coretexpylib").error(f"\tError while creating artifact: {e}")
logging.getLogger("coretexpylib").debug(f"\tError while creating artifact: {e}", exc_info = e)

if timeit.default_timer() - lastTimeHeartbeat > 5:
logging.getLogger("coretexpylib").debug(">> [Coretex] Heartbeat")
taskRun.updateStatus() # updateStatus without params is considered heartbeat
lastTimeHeartbeat = timeit.default_timer()

0 comments on commit 7bdc793

Please sign in to comment.