class tensorstore.Promise[T]

Handle for producing the result of an asynchronous operation.

A promise represents the producer interface corresponding to a Future, and may be used to signal the completion of an asynchronous operation.

>>> promise, future = ts.Promise.new()
>>> future.done()
False
>>> promise.set_result(5)
>>> future.done()
True
>>> future.result()
5

Promise and Future can also be used with type :param >>> promise: :param future = ts.Promise[int].new(): :param >>> typing.assert_type: :type >>> typing.assert_type: promise, ts.Promise[int] :param >>> typing.assert_type: :type >>> typing.assert_type: future, ts.Future[int] :param >>> promise.set_result: :type >>> promise.set_result: 5 :param >>> future.result(): :param 5:

See also

Type Parameters:
T

Result type of the asynchronous operation.

Operations

set_result(result: T) None

Marks the linked future as successfully completed with the specified result.

set_exception(exception: object) None

Marks the linked future as unsuccessfully completed with the specified error.

Constructors

static new() tuple[Promise[T], Future[T]]

Creates a linked promise and future pair.