88import time
99import traceback
1010import warnings
11+ import abc
1112
1213from .notebook_integration import live_plot , live_info , in_ipynb
1314from .utils import timed
@@ -53,8 +54,8 @@ def _default_executor(*args, **kwargs):
5354 _default_executor_kwargs = {}
5455
5556
56- class BaseRunner :
57- """Base class for runners that use ` concurrent.futures.Executors` .
57+ class BaseRunner ( metaclass = abc . ABCMeta ) :
58+ """Base class for runners that use concurrent.futures.Executors.
5859
5960 Parameters
6061 ----------
@@ -241,6 +242,16 @@ def _cleanup(self):
241242 def failed (self ):
242243 """Set of points that failed ``runner.retries`` times."""
243244 return set (self .tracebacks ) - set (self .to_retry )
245+
246+ @abc .abstractmethod
247+ def elapsed_time (self ):
248+ """Is called in 'overhead'."""
249+ pass
250+
251+ @abc .abstractmethod
252+ def _submit (self , x ):
253+ """Is called in '_get_futures'."""
254+ pass
244255
245256
246257class BlockingRunner (BaseRunner ):
@@ -444,9 +455,9 @@ def goal(_):
444455 raise RuntimeError ('Cannot use an executor when learning an '
445456 'async function.' )
446457 self .executor .shutdown () # Make sure we don't shoot ourselves later
447- self ._submit = lambda x : self .ioloop .create_task (self .function (x ))
458+ self .__submit = lambda x : self .ioloop .create_task (self .function (x ))
448459 else :
449- self ._submit = functools .partial (self .ioloop .run_in_executor ,
460+ self .__submit = functools .partial (self .ioloop .run_in_executor ,
450461 self .executor ,
451462 self .function )
452463
@@ -458,6 +469,9 @@ def goal(_):
458469 "in a Jupyter notebook, remember to run "
459470 "'adaptive.notebook_extension()'" )
460471
472+ def _submit (self , x ):
473+ return self .__submit (x )
474+
461475 def status (self ):
462476 """Return the runner status as a string.
463477
0 commit comments