question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

async Client with sync LocalCluster

See original GitHub issue

When a Client is passed a LocalCluster and the asynchronous=True flag, it silently ignores the explicit flag and gets it from the cluster instead.

>>> cluster = await distributed.LocalCluster(asynchronous=True)
>>> client = await distributed.Client(cluster, asynchronous=True)
>>> client.asynchronous
True
>>> cluster = distributed.LocalCluster()
>>> client = await distributed.Client(cluster, asynchronous=True)
>>> client.asynchronous
False
>>> cluster = distributed.LocalCluster()
>>> client = await distributed.Client(cluster.scheduler.address, asynchronous=True)
>>> client.asynchronous
True

The same happens for an eventual explicit loop parameter. Both issues are caused by these lines, which cause Client.loop to be forced to match Client.cluster.loop: https://github.com/dask/distributed/blob/9f91653398aee681ba0010b1053f3bd1b415894b/distributed/client.py#L647-L653

I see in the code how a few things will break if the client and client.cluster end up having two different event loops. Not sure what the correct solution would be?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mrocklincommented, May 11, 2020

Yes, I think that erring loudly in this case, perhaps with the workaround that you suggested with the address would be a good solution.

On Mon, May 11, 2020 at 8:51 AM crusaderky notifications@github.com wrote:

I don’t have a use case for two event loops, but when prototyping on jupyter notebook, if I need particular worker settings, I typically find it useful to write cluster and worker on two separate lines. If the client is asynchronous, i frequently forget to set the asynchronous flag on the cluster.

Should I simply implement a check that, if address is a cluster, then the loop and asynchronous parameters must either be omitted or match those of the cluster?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dask/distributed/issues/3789#issuecomment-626788546, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACKZTAIK3NQHSV7HEEMT4DRRANHTANCNFSM4M5XRIXQ .

0reactions
lmeyerovcommented, Jan 2, 2021

FWIW, we’re seeing the reverse need in GPU land: sync client to an async cluster.

– Most of our code is async client <> async cluster – Many libs (ex: blazingsql) assume sync client, which seems to require a sync cluster – We don’t want 2 clusters, as dask_cudf / RMM takes ~300MB baseline per instance – … so we’d like to occasionally generate a sync client to an existing async cluster

Read more comments on GitHub >

github_iconTop Results From Across the Web

API — Dask.distributed 2022.12.1 documentation
The Client connects users to a Dask cluster. It provides an asynchronous user interface around functions and futures. This class resembles executors in ......
Read more >
LocalCluster (Storm 2.3.0 API)
A stand alone storm cluster that runs inside a single process. It is intended to be used for testing. Both internal testing for...
Read more >
Async client with sync server - Google Groups
Is it possible to have an async client while the server remains 'sync'. This could be handy for a use case where I...
Read more >
Libraries and tools - etcd
Async HTTP client based on Netty and Scala Futures. mingchuno/etcd4s ... A set of distributed synchronization primitives built upon etcd ...
Read more >
python-distributed-1.25.3-bp152.3.19 - SUSE Package Hub -
... Matthew Rocklin * Support async def functions in Client.sync (GH#2070) Matthew Rocklin * Add asynchronous parameter to docstring of LocalCluster Matthew ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found