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 @@ -259,6 +259,11 @@ def _process_futures(self, done_futs):
259
259
try :
260
260
y = fut .result ()
261
261
t = time .time () - fut .start_time # total execution time
262
+ except asyncio .CancelledError :
263
+ # Cleanup
264
+ self ._to_retry .pop (pid , None )
265
+ self ._tracebacks .pop (pid , None )
266
+ self ._id_to_point .pop (pid , None )
262
267
except Exception as e :
263
268
self ._tracebacks [pid ] = traceback .format_exc ()
264
269
self ._to_retry [pid ] = self ._to_retry .get (pid , 0 ) + 1
@@ -754,6 +759,22 @@ def elapsed_time(self):
754
759
end_time = time .time ()
755
760
return end_time - self .start_time
756
761
762
+ def cancel_point (
763
+ self , point : Any | None = None , future : asyncio .Future | None = None
764
+ ):
765
+ """Cancel a point that is currently being evaluated.
766
+
767
+ Parameters
768
+ ----------
769
+ point
770
+ The point that should be cancelled.
771
+ """
772
+ if point is None and future is None :
773
+ raise ValueError ("Either point or future must be given" )
774
+ if future is None :
775
+ future = next (fut for fut , p in self .pending_points if p == point )
776
+ future .cancel ()
777
+
757
778
def add_periodic_callback (
758
779
self ,
759
780
method : Callable [[AsyncRunner ]],
You can’t perform that action at this time.
0 commit comments