Skip to content
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

introduce fire_and_forget #127

Merged
merged 1 commit into from
Aug 29, 2024
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
9 changes: 7 additions & 2 deletions cads_broker/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,8 @@ def sync_database(self, session: sa.orm.Session) -> None:
if state == "memory":
# if the task is in memory and it is not in the futures
# it means that the task has been lost by the broker (broker has been restarted)
# the task is successful. If the function returns None it means that the request
# has already been set to successful
# the task is successful. If the "set_successful_request" function returns None
# it means that the request has already been set to successful
finished_request = db.set_successful_request(
request_uid=request.request_uid,
session=session,
Expand All @@ -417,6 +417,9 @@ def sync_database(self, session: sa.orm.Session) -> None:
dask_status=task["state"],
**db.logger_kwargs(request=finished_request),
)
# if the task is in processing, it means that the task is still running
if state == "processing":
continue
# if it doesn't find the request: re-queue it
else:
request = db.get_request(request.request_uid, session=session)
Expand All @@ -433,6 +436,7 @@ def sync_database(self, session: sa.orm.Session) -> None:
"job has finished",
**db.logger_kwargs(request=successful_request),
)
continue
# FIXME: check if request status has changed
if os.getenv(
"BROKER_REQUEUE_ON_LOST_REQUESTS", True
Expand Down Expand Up @@ -603,6 +607,7 @@ def submit_request(
resources=request.request_metadata.get("resources", {}),
metadata=request.request_metadata,
)
distributed.fire_and_forget(future)
self.futures[request.request_uid] = future
logger.info(
"submitted job to scheduler",
Expand Down
Loading