tensorstore.Future(future: FutureLike, *, loop: asyncio.AbstractEventLoop | None = None)

Converts a FutureLike object to a Future.

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 (or None is specified), defaults to the loop returned by asyncio.get_running_loop. If loop is not specified and there is no running event loop, it is an error for future to be a coroutine.

Returns:

Warning

If future is a coroutine, a blocking call to Future.result or Future.exception in the thread running the associated event loop may lead to deadlock. Blocking calls should be avoided when using an event loop.