Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import contextvars
import threading

from sqlalchemy import update
Expand All @@ -24,17 +25,15 @@ def heartbeat_loop() -> None:
.values(heartbeat_counter=IndexAttempt.heartbeat_counter + 1)
)
db_session.commit()
logger.debug(
"Updated heartbeat counter for index attempt %s",
index_attempt_id,
)
except Exception:
logger.exception(
"Failed to update heartbeat counter for index attempt %s",
index_attempt_id,
)

thread = threading.Thread(target=heartbeat_loop, daemon=True)
# Ensure contextvars from the outer context are available in the thread
context = contextvars.copy_context()
thread = threading.Thread(target=context.run, args=(heartbeat_loop,), daemon=True)
thread.start()
return thread, stop_event

Expand Down
Loading