TensorPlay
API symbolsfutures
Copy
View MarkdownDownload .md

Future

class tensorplay.futures.Future(*, _completer: Callable[[], Any] | None = None)[source]

Holder for an asynchronous result (torch parity subset).

Example:

>>> fut = tp.futures.Future()
>>> fut.set_result(1)
>>> fut.value()
1
>>> chained = other.then(lambda f: f.value()[0])
>>> chained.value()
tensor(...)
add_done_callback(callback: Callable[[Future], Any]) None[source]

Appends a callback run when this future completes.

done() bool[source]

Returns whether the future is complete (non-blocking).

is_done() bool[source]

Alias of done().

set_result(result: Any) None[source]

Sets the result value and fires callbacks (torch parity).

then(callback: Callable[[Future], Any]) Future[source]

Adds a callback mapped over this future; returns the new future.

The callback receives this future and its return value becomes the derived future’s result (torch Future.then contract).

value() Any[source]

Gets the result value, blocking until it completes.

Raises RuntimeError on error results (mirrors torch’s ValueError-on-error behavior loosely; tp stores exceptions as results and re-raises them here).

wait() Any[source]

Blocks until complete and returns the result value.

Ask DeepWiki