File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 6060 FutureCompletedError * = object of FutureError
6161 # # Error raised when trying access the error of a completed Future
6262
63- SomeFuture = Future | InternalRaisesFuture
63+ SomeFuture * = Future | InternalRaisesFuture
6464
6565func raiseFuturePendingError (fut: FutureBase ) {.
6666 noinline , noreturn , raises : FuturePendingError .} =
@@ -1241,6 +1241,15 @@ proc one*[F: SomeFuture](futs: openArray[F]): Future[F] {.
12411241
12421242 oneImpl
12431243
1244+ proc oneCancel * [F: SomeFuture ](futs: varargs [F]): Future [F] {.
1245+ async : (raw: true , raises: [ValueError , CancelledError ]).} =
1246+ try :
1247+ await one (futs)
1248+ finally :
1249+ for f in futs:
1250+ if not f.completed:
1251+ await f.cancelAndWait ()
1252+
12441253template raceImpl =
12451254 # If one of the Future[T] already finished we return it as result
12461255 for fut in futs:
You can’t perform that action at this time.
0 commit comments