... | ... |
@@ -240,12 +240,19 @@ class AsyncRunner(BaseRunner): |
240 | 240 |
self.executor, |
241 | 241 |
self.learner.function) |
242 | 242 |
|
243 |
+ self.start_time = time.time() |
|
244 |
+ self.end_time = None |
|
245 |
+ |
|
243 | 246 |
if in_ipynb() and not self.ioloop.is_running(): |
244 | 247 |
warnings.warn('The runner has been scheduled, but no event loop is ' |
245 | 248 |
'running! Run adaptive.notebook_extension() to use ' |
246 | 249 |
'the Runner in a Jupyter notebook.') |
247 | 250 |
self.task = self.ioloop.create_task(self._run()) |
248 | 251 |
|
252 |
+ def elapsed_time(self): |
|
253 |
+ end_time = self.end_time if self.task.done() else time.time() |
|
254 |
+ return end_time - self.start_time |
|
255 |
+ |
|
249 | 256 |
def cancel(self): |
250 | 257 |
"""Cancel the runner. |
251 | 258 |
|
... | ... |
@@ -295,6 +302,7 @@ class AsyncRunner(BaseRunner): |
295 | 302 |
await asyncio.wait(remaining) |
296 | 303 |
if self.shutdown_executor: |
297 | 304 |
self.executor.shutdown(wait=False) |
305 |
+ self.end_time = time.time() |
|
298 | 306 |
|
299 | 307 |
|
300 | 308 |
# Default runner |