diff --git a/adaptive/runner.py b/adaptive/runner.py index b6d0de494833ded337cbab87cd9045b42eb1327f..f3b84b3467e409a18f6784b16936a0a3c2d9e66a 100644 --- a/adaptive/runner.py +++ b/adaptive/runner.py @@ -338,6 +338,8 @@ class BlockingRunner(BaseRunner): self._cleanup() def elapsed_time(self): + """Return the total time elapsed since the runner + was started.""" if self.end_time is None: # This shouldn't happen if the BlockingRunner # correctly finished. @@ -532,6 +534,8 @@ class AsyncRunner(BaseRunner): self._cleanup() def elapsed_time(self): + """Return the total time elapsed since the runner + was started.""" if self.task.done(): end_time = self.end_time if end_time is None: diff --git a/docs/source/tutorial/tutorial.advanced-topics.rst b/docs/source/tutorial/tutorial.advanced-topics.rst index d6eabd27424304a23868e4a770b89bcf68944637..aead0dd416f04dfa40f15da19f0654800f644969 100644 --- a/docs/source/tutorial/tutorial.advanced-topics.rst +++ b/docs/source/tutorial/tutorial.advanced-topics.rst @@ -298,6 +298,15 @@ raise the exception with the stack trace: runner.task.result() + +You can also check ``runner.tracebacks`` which is a mapping from +point → traceback. + +.. jupyter-execute:: + + for point, tb in runner.tracebacks.items(): + print(f'point: {point}:\n {tb}') + Logging runners ~~~~~~~~~~~~~~~ @@ -337,10 +346,16 @@ set of operations on another runner: learner.plot().Scatter.I.opts(style=dict(size=6)) * reconstructed_learner.plot() -Timing functions -~~~~~~~~~~~~~~~~ +Adding coroutines +----------------- + +In the following example we'll add a `~asyncio.Task` that times the runner. +This is *only* for demonstration purposes because one can simply +check ``runner.elapsed_time()`` or use the ``runner.live_info()`` +widget to see the time since the runner has started. -To time the runner you **cannot** simply use +So let's get on with the example. To time the runner +you **cannot** simply use .. code:: python