8
8
import time
9
9
import traceback
10
10
import warnings
11
+ import abc
11
12
12
13
from .notebook_integration import live_plot , live_info , in_ipynb
13
14
from .utils import timed
@@ -53,8 +54,8 @@ def _default_executor(*args, **kwargs):
53
54
_default_executor_kwargs = {}
54
55
55
56
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.
58
59
59
60
Parameters
60
61
----------
@@ -241,6 +242,16 @@ def _cleanup(self):
241
242
def failed (self ):
242
243
"""Set of points that failed ``runner.retries`` times."""
243
244
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
244
255
245
256
246
257
class BlockingRunner (BaseRunner ):
@@ -444,9 +455,9 @@ def goal(_):
444
455
raise RuntimeError ('Cannot use an executor when learning an '
445
456
'async function.' )
446
457
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 ))
448
459
else :
449
- self ._submit = functools .partial (self .ioloop .run_in_executor ,
460
+ self .__submit = functools .partial (self .ioloop .run_in_executor ,
450
461
self .executor ,
451
462
self .function )
452
463
@@ -458,6 +469,9 @@ def goal(_):
458
469
"in a Jupyter notebook, remember to run "
459
470
"'adaptive.notebook_extension()'" )
460
471
472
+ def _submit (self , x ):
473
+ return self .__submit (x )
474
+
461
475
def status (self ):
462
476
"""Return the runner status as a string.
463
477
0 commit comments