Skip to content

alert on subscription failure, and shutdown returns an empty list #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions hedwig/backends/gcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def shutdown(self, await_msg_callbacks=False) -> None:
"""Shuts down the scheduler and immediately end all pending callbacks."""
# ideally we'd nack the messages in work queue, but that might take some time to finish.
# instead, it's faster to actually process all the messages
return []


class GooglePubSubConsumerBackend(HedwigConsumerBaseBackend):
Expand Down Expand Up @@ -269,6 +270,14 @@ def pull_messages(
)
)

for future in futures:
try:
future.result(timeout=0.3)
except TimeoutError:
pass
except Exception:
log(__name__, logging.ERROR, "Error with subscription", exc_info=True)

while not shutdown_event.is_set():
try:
message = work_queue.get(timeout=1)
Expand Down