@@ -26,6 +26,10 @@ class ExecutorState(TypedDict):
2626 If the executor is not idle, then None.
2727 """
2828
29+ first : bool
30+ """Is this the first poll for this executor?
31+ """
32+
2933
3034class Strategy :
3135 """Scaling strategy.
@@ -144,17 +148,17 @@ def __init__(self, *, strategy: Optional[str], max_idletime: float) -> None:
144148
145149 def add_executors (self , executors : Sequence [ParslExecutor ]) -> None :
146150 for executor in executors :
147- self .executors [executor .label ] = {'idle_since' : None }
151+ self .executors [executor .label ] = {'idle_since' : None , 'first' : True }
148152
149153 def _strategy_init_only (self , status_list : List [jsp .PolledExecutorFacade ]) -> None :
150154 """Scale up to init_blocks at the start, then nothing more.
151155 """
152156 for exec_status in status_list :
153- if exec_status .first :
154- executor = exec_status . executor
157+ executor = exec_status .executor
158+ if self . executors [ executor . label ][ 'first' ]:
155159 logger .debug (f"strategy_init_only: scaling out { executor .provider .init_blocks } initial blocks for { executor .label } " )
156160 exec_status .scale_out (executor .provider .init_blocks )
157- exec_status . first = False
161+ self . executors [ executor . label ][ ' first' ] = False
158162 else :
159163 logger .debug ("strategy_init_only: doing nothing" )
160164
@@ -190,11 +194,11 @@ def _general_strategy(self, status_list, *, strategy_type):
190194 continue
191195 logger .debug (f"Strategizing for executor { label } " )
192196
193- if exec_status . first :
197+ if self . executors [ label ][ ' first' ] :
194198 executor = exec_status .executor
195199 logger .debug (f"Scaling out { executor .provider .init_blocks } initial blocks for { label } " )
196200 exec_status .scale_out (executor .provider .init_blocks )
197- exec_status . first = False
201+ self . executors [ label ][ ' first' ] = False
198202
199203 # Tasks that are either pending completion
200204 active_tasks = executor .outstanding
0 commit comments