@@ -4683,53 +4683,48 @@ def handle_task_erred(self, key: str, stimulus_id: str, **msg) -> None:
4683
4683
self .send_all (client_msgs , worker_msgs )
4684
4684
4685
4685
def handle_missing_data (
4686
- self , key : str , errant_worker : str , stimulus_id : str , ** kwargs
4686
+ self , key : str , worker : str , errant_worker : str , stimulus_id : str
4687
4687
) -> None :
4688
- """Signal that `errant_worker` does not hold `key`
4688
+ """Signal that `errant_worker` does not hold `key`.
4689
4689
4690
- This may either indicate that `errant_worker` is dead or that we may be
4691
- working with stale data and need to remove `key` from the workers
4692
- `has_what`.
4693
-
4694
- If no replica of a task is available anymore, the task is transitioned
4695
- back to released and rescheduled, if possible.
4690
+ This may either indicate that `errant_worker` is dead or that we may be working
4691
+ with stale data and need to remove `key` from the workers `has_what`. If no
4692
+ replica of a task is available anymore, the task is transitioned back to
4693
+ released and rescheduled, if possible.
4696
4694
4697
4695
Parameters
4698
4696
----------
4699
- key : str, optional
4700
- Task key that could not be found, by default None
4701
- errant_worker : str, optional
4702
- Address of the worker supposed to hold a replica, by default None
4697
+ key : str
4698
+ Task key that could not be found
4699
+ worker : str
4700
+ Address of the worker informing the scheduler
4701
+ errant_worker : str
4702
+ Address of the worker supposed to hold a replica
4703
4703
"""
4704
- logger .debug ("handle missing data key=%s worker=%s" , key , errant_worker )
4704
+ logger .debug (f "handle missing data { key = } { worker = } { errant_worker = } " )
4705
4705
self .log_event (errant_worker , {"action" : "missing-data" , "key" : key })
4706
4706
4707
- if key not in self .tasks :
4707
+ ts = self .tasks .get (key )
4708
+ ws = self .workers .get (errant_worker )
4709
+ if not ts or not ws or ws not in ts .who_has :
4708
4710
return
4709
4711
4710
- ts : TaskState = self .tasks [key ]
4711
- ws : WorkerState = self .workers .get (errant_worker )
4712
-
4713
- if ws is not None and ws in ts .who_has :
4714
- self .remove_replica (ts , ws )
4712
+ self .remove_replica (ts , ws )
4715
4713
if ts .state == "memory" and not ts .who_has :
4716
4714
if ts .run_spec :
4717
4715
self .transitions ({key : "released" }, stimulus_id )
4718
4716
else :
4719
4717
self .transitions ({key : "forgotten" }, stimulus_id )
4720
4718
4721
- def release_worker_data (self , key , worker , stimulus_id ) :
4722
- ws : WorkerState = self .workers .get (worker )
4723
- ts : TaskState = self .tasks .get (key )
4724
- if not ws or not ts :
4719
+ def release_worker_data (self , key : str , worker : str , stimulus_id : str ) -> None :
4720
+ ts = self .tasks .get (key )
4721
+ ws = self .workers .get (worker )
4722
+ if not ts or not ws or ws not in ts . who_has :
4725
4723
return
4726
- recommendations : dict = {}
4727
- if ws in ts .who_has :
4728
- self .remove_replica (ts , ws )
4729
- if not ts .who_has :
4730
- recommendations [ts .key ] = "released"
4731
- if recommendations :
4732
- self .transitions (recommendations , stimulus_id )
4724
+
4725
+ self .remove_replica (ts , ws )
4726
+ if not ts .who_has :
4727
+ self .transitions ({key : "released" }, stimulus_id )
4733
4728
4734
4729
def handle_long_running (self , key = None , worker = None , compute_duration = None ):
4735
4730
"""A task has seceded from the thread pool
@@ -4907,7 +4902,7 @@ async def register_scheduler_plugin(self, plugin, name=None, idempotent=None):
4907
4902
4908
4903
self .add_plugin (plugin , name = name , idempotent = idempotent )
4909
4904
4910
- def worker_send (self , worker , msg ) :
4905
+ def worker_send (self , worker : str , msg : dict [ str , Any ]) -> None :
4911
4906
"""Send message to worker
4912
4907
4913
4908
This also handles connection failures by adding a callback to remove
0 commit comments