@@ -1431,6 +1431,21 @@ def new_task(
14311431
14321432 return ts
14331433
1434+ def _clear_task_state (self ):
1435+
1436+ logger .debug ("Clear task state" )
1437+ for collection in [
1438+ self .unrunnable ,
1439+ self .erred_tasks ,
1440+ self .computations ,
1441+ self .task_prefixes ,
1442+ self .task_groups ,
1443+ self .task_metadata ,
1444+ self .unknown_durations ,
1445+ self .replicated_tasks ,
1446+ ]:
1447+ collection .clear ()
1448+
14341449 #####################
14351450 # State Transitions #
14361451 #####################
@@ -3098,8 +3113,6 @@ def __init__(
30983113 resources = {}
30993114 aliases = {}
31003115
3101- self ._task_state_collections = [unrunnable ]
3102-
31033116 self ._worker_collections = [
31043117 workers ,
31053118 host_info ,
@@ -3400,7 +3413,7 @@ async def start_unsafe(self):
34003413
34013414 enable_gc_diagnosis ()
34023415
3403- self .clear_task_state ()
3416+ self ._clear_task_state ()
34043417
34053418 for addr in self ._start_address :
34063419 await self .listen (
@@ -5183,13 +5196,6 @@ async def gather(self, keys, serializers=None):
51835196 self .log_event ("all" , {"action" : "gather" , "count" : len (keys )})
51845197 return result
51855198
5186- def clear_task_state (self ):
5187- # XXX what about nested state such as ClientState.wants_what
5188- # (see also fire-and-forget...)
5189- logger .info ("Clear task state" )
5190- for collection in self ._task_state_collections :
5191- collection .clear ()
5192-
51935199 @log_errors
51945200 async def restart (self , client = None , timeout = 30 , wait_for_workers = True ):
51955201 """
@@ -5229,9 +5235,8 @@ async def restart(self, client=None, timeout=30, wait_for_workers=True):
52295235 stimulus_id = stimulus_id ,
52305236 )
52315237
5232- self .clear_task_state ()
5233- self .erred_tasks .clear ()
5234- self .computations .clear ()
5238+ self ._clear_task_state ()
5239+ assert not self .tasks
52355240 self .report ({"op" : "restart" })
52365241
52375242 for plugin in list (self .plugins .values ()):
0 commit comments