Skip to content

Issue switching between synchronous and asynchronous mode with Client #2853

Description

@pierreglaser

Hi,
I played around with distributed to solve joblib/joblib#852, especially the ability of Client to switch from sync to async mode.

The documentation seems to state that it is possible:

If you want to reuse the same client in asynchronous and synchronous
environments you can apply the ``asynchronous=True`` keyword at each method
call.
.. code-block:: python
client = Client() # normal blocking client
async def f():
futures = client.map(func, L)
results = await client.gather(futures, asynchronous=True)
return results

But the following script just hangs forever without outputing anything.

from tornado.ioloop import IOLoop
from distributed import Client


async def f():
    results = client.map(lambda x: x, [(1,), (2,)])
    results = await client.gather(results, asynchronous=True)
    return results


if __name__ == "__main__":
    client = Client()
    res = IOLoop.current().run_sync(f)
    print("final result: {}".format(res))

When using Client(asynchronous=True) instead, the scripts runs fine.
Is it expected behavior?

Using python3.7, distributed master, tornado 6.0.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions