-
tensorstore.Future(future: FutureLike, *, loop: asyncio.AbstractEventLoop | None =
None
) Converts a
FutureLike
object to aFuture
.Example
>>> await ts.Future(3) 3
>>> x = ts.Future(3) >>> assert x is ts.Future(x)
>>> async def get_value(): ... return 42 >>> x = ts.Future(get_value()) >>> x.done() False >>> await x >>> x.result() 42
- Parameters:¶
- future: FutureLike¶
Specifies the immediate or asynchronous result.
- loop: asyncio.AbstractEventLoop | None =
None
¶ Event loop on which to run
future
if it is a coroutine. If not specified (orNone
is specified), defaults to the loop returned byasyncio.get_running_loop
. Ifloop
is not specified and there is no running event loop, it is an error forfuture
to be a coroutine.
- Returns:¶
Warning
If
future
is a coroutine, a blocking call toFuture.result
orFuture.exception
in the thread running the associated event loop may lead to deadlock. Blocking calls should be avoided when using an event loop.