...
|
...
|
@@ -128,7 +128,7 @@ class BaseRunner(metaclass=abc.ABCMeta):
|
128
|
128
|
|
129
|
129
|
self._max_tasks = ntasks
|
130
|
130
|
|
131
|
|
- self._pending_pids = {}
|
|
131
|
+ self._pending_tasks = {} # mapping from concurrent.futures.Future → point id
|
132
|
132
|
|
133
|
133
|
# if we instantiate our own executor, then we are also responsible
|
134
|
134
|
# for calling 'shutdown'
|
...
|
...
|
@@ -170,7 +170,7 @@ class BaseRunner(metaclass=abc.ABCMeta):
|
170
|
170
|
return self.log is not None
|
171
|
171
|
|
172
|
172
|
def _ask(self, n):
|
173
|
|
- pending_ids = self._pending_pids.values()
|
|
173
|
+ pending_ids = self._pending_tasks.values()
|
174
|
174
|
pids_gen = (pid for pid in self._to_retry.keys() if pid not in pending_ids)
|
175
|
175
|
pids = list(itertools.islice(pids_gen, n))
|
176
|
176
|
|
...
|
...
|
@@ -210,7 +210,7 @@ class BaseRunner(metaclass=abc.ABCMeta):
|
210
|
210
|
|
211
|
211
|
def _process_futures(self, done_futs):
|
212
|
212
|
for fut in done_futs:
|
213
|
|
- pid = self._pending_pids.pop(fut)
|
|
213
|
+ pid = self._pending_tasks.pop(fut)
|
214
|
214
|
try:
|
215
|
215
|
y = fut.result()
|
216
|
216
|
t = time.time() - fut.start_time # total execution time
|
...
|
...
|
@@ -234,7 +234,7 @@ class BaseRunner(metaclass=abc.ABCMeta):
|
234
|
234
|
# Launch tasks to replace the ones that completed
|
235
|
235
|
# on the last iteration, making sure to fill workers
|
236
|
236
|
# that have started since the last iteration.
|
237
|
|
- n_new_tasks = max(0, self._get_max_tasks() - len(self._pending_pids))
|
|
237
|
+ n_new_tasks = max(0, self._get_max_tasks() - len(self._pending_tasks))
|
238
|
238
|
|
239
|
239
|
if self.do_log:
|
240
|
240
|
self.log.append(("ask", n_new_tasks))
|
...
|
...
|
@@ -246,17 +246,17 @@ class BaseRunner(metaclass=abc.ABCMeta):
|
246
|
246
|
point = self._id_to_point[pid]
|
247
|
247
|
fut = self._submit(point)
|
248
|
248
|
fut.start_time = start_time
|
249
|
|
- self._pending_pids[fut] = pid
|
|
249
|
+ self._pending_tasks[fut] = pid
|
250
|
250
|
|
251
|
251
|
# Collect and results and add them to the learner
|
252
|
|
- futures = list(self._pending_pids.keys())
|
|
252
|
+ futures = list(self._pending_tasks.keys())
|
253
|
253
|
return futures
|
254
|
254
|
|
255
|
255
|
def _remove_unfinished(self):
|
256
|
256
|
# remove points with 'None' values from the learner
|
257
|
257
|
self.learner.remove_unfinished()
|
258
|
258
|
# cancel any outstanding tasks
|
259
|
|
- remaining = list(self._pending_pids.keys())
|
|
259
|
+ remaining = list(self._pending_tasks.keys())
|
260
|
260
|
for fut in remaining:
|
261
|
261
|
fut.cancel()
|
262
|
262
|
return remaining
|
...
|
...
|
@@ -302,7 +302,7 @@ class BaseRunner(metaclass=abc.ABCMeta):
|
302
|
302
|
@property
|
303
|
303
|
def pending_points(self):
|
304
|
304
|
return [
|
305
|
|
- (fut, self._id_to_point[pid]) for fut, pid in self._pending_pids.items()
|
|
305
|
+ (fut, self._id_to_point[pid]) for fut, pid in self._pending_tasks.items()
|
306
|
306
|
]
|
307
|
307
|
|
308
|
308
|
|