Skip to content

Commit 9f4fcbd

Browse files
introduce fire_and_forget (#127)
1 parent 6797f64 commit 9f4fcbd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cads_broker/dispatcher.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,8 @@ def sync_database(self, session: sa.orm.Session) -> None:
395395
if state == "memory":
396396
# if the task is in memory and it is not in the futures
397397
# it means that the task has been lost by the broker (broker has been restarted)
398-
# the task is successful. If the function returns None it means that the request
399-
# has already been set to successful
398+
# the task is successful. If the "set_successful_request" function returns None
399+
# it means that the request has already been set to successful
400400
finished_request = db.set_successful_request(
401401
request_uid=request.request_uid,
402402
session=session,
@@ -418,6 +418,9 @@ def sync_database(self, session: sa.orm.Session) -> None:
418418
dask_status=task["state"],
419419
**db.logger_kwargs(request=finished_request),
420420
)
421+
# if the task is in processing, it means that the task is still running
422+
if state == "processing":
423+
continue
421424
# if it doesn't find the request: re-queue it
422425
else:
423426
request = db.get_request(request.request_uid, session=session)
@@ -434,6 +437,7 @@ def sync_database(self, session: sa.orm.Session) -> None:
434437
"job has finished",
435438
**db.logger_kwargs(request=successful_request),
436439
)
440+
continue
437441
# FIXME: check if request status has changed
438442
if os.getenv(
439443
"BROKER_REQUEUE_ON_LOST_REQUESTS", True
@@ -604,6 +608,7 @@ def submit_request(
604608
resources=request.request_metadata.get("resources", {}),
605609
metadata=request.request_metadata,
606610
)
611+
distributed.fire_and_forget(future)
607612
self.futures[request.request_uid] = future
608613
logger.info(
609614
"submitted job to scheduler",

0 commit comments

Comments
 (0)