File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -223,6 +223,11 @@ def _process_futures(self, done_futs):
223
223
try :
224
224
y = fut .result ()
225
225
t = time .time () - fut .start_time # total execution time
226
+ except asyncio .CancelledError :
227
+ # Cleanup
228
+ self ._to_retry .pop (pid , None )
229
+ self ._tracebacks .pop (pid , None )
230
+ self ._id_to_point .pop (pid , None )
226
231
except Exception as e :
227
232
self ._tracebacks [pid ] = traceback .format_exc ()
228
233
self ._to_retry [pid ] = self ._to_retry .get (pid , 0 ) + 1
@@ -670,6 +675,22 @@ def elapsed_time(self):
670
675
end_time = time .time ()
671
676
return end_time - self .start_time
672
677
678
+ def cancel_point (
679
+ self , point : Any | None = None , future : asyncio .Future | None = None
680
+ ):
681
+ """Cancel a point that is currently being evaluated.
682
+
683
+ Parameters
684
+ ----------
685
+ point
686
+ The point that should be cancelled.
687
+ """
688
+ if point is None and future is None :
689
+ raise ValueError ("Either point or future must be given" )
690
+ if future is None :
691
+ future = next (fut for fut , p in self .pending_points if p == point )
692
+ future .cancel ()
693
+
673
694
def add_periodic_callback (
674
695
self ,
675
696
method : Callable [[AsyncRunner ]],
You can’t perform that action at this time.
0 commit comments