From 05b8d669d00b1a9a6b3e5233e222935445c37145 Mon Sep 17 00:00:00 2001 From: Florian Jetter Date: Mon, 10 Jun 2024 14:34:53 +0200 Subject: [PATCH] Add section about futures and variables (#11164) Co-authored-by: Patrick Hoefler <61934744+phofl@users.noreply.github.com> --- docs/source/futures.rst | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/source/futures.rst b/docs/source/futures.rst index c624c9e9bfe..bbaadc33d88 100644 --- a/docs/source/futures.rst +++ b/docs/source/futures.rst @@ -340,6 +340,30 @@ part of a function: process(filename) +Submit task and retrieve results from a different process +--------------------------------------------------------- + +Sometimes we care about retrieving a result but not necessarily from the same process. + +.. code-block:: python + + from distributed import Variable + + var = Variable("my-result") + fut = client.submit(...) + var.set(fut) + +Using a ``Variable`` instructs dask to remember the result of this task under +the given name so that it can be retrieved later without having to keep the +Client alive in the meantime. + +.. code-block:: python + + var = Variable("my-result") + fut = var.get() + result = fut.result() + + Submit Tasks from Tasks -----------------------