Skip to content

Commit

Permalink
Expand async docs (#2293)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Hirschfeld authored and jrbourbeau committed Nov 7, 2019
1 parent 0766d78 commit d575ea0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ continuous_integration/hdfs-initialized
*.lock
.#*
.idea/
.vscode/
.pytest_cache/
dask-worker-space/
.vscode/
Expand Down
18 changes: 12 additions & 6 deletions docs/source/asynchronous.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,24 @@ received information from the scheduler should now be ``await``'ed.
result = await client.gather(future)
If you want to reuse the same client in asynchronous and synchronous
environments you can apply the ``asynchronous=True`` keyword at each method
call.
If you want to use an asynchronous function with a synchronous ``Client``
(one made without the ``asynchronous=True`` keyword) then you can apply the
``asynchronous=True`` keyword at each method call and use the ``Client.sync``
function to run the asynchronous function:

.. code-block:: python
from dask.distributed import Client
client = Client() # normal blocking client
async def f():
futures = client.map(func, L)
results = await client.gather(futures, asynchronous=True)
return results
future = client.submit(lambda x: x + 1, 10)
result = await client.gather(future, asynchronous=True)
return result
client.sync(f)
Python 2 Compatibility
Expand Down

0 comments on commit d575ea0

Please sign in to comment.