dask / dask/distributed

Creating a Client with set_as_default=False sets client as default

Open
#5,425 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.7k
Forks
778
Avg merge
2h 50m
Merged PRs (30d)
3

Description

**What happened**:

If I create a Client with `set_as_default=False` in the arguments, the client still gets set as the default.

**What you expected to happen**:

The client that I create should not be set as the default client.

**Minimal Complete Verifiable Example**:

```python
>>> from distributed import Client, default_client
>>> default_client()
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.8/site-packages/distributed-2.25.0-py3.8.egg/distributed/client.py", line 4550, in default_client
raise ValueError(
ValueError: No clients found
Start a client and point it to the scheduler address
from distributed import Client
client = Client('ip-addr-of-scheduler:8786')

>>> c = Client(set_as_default=False)
>>> c

>>> default_client()

>>> c == default_client()
True
```

The `default_client()` calls after creating a client with `set_as_default=False` should throw a `ValueError` just like before creating the client.

**Anything else we need to know?**:

None.

**Environment**:

- Dask version: 2.25.0
- Python version: 3.8.5
- Operating System: Linux f9c08655086d 4.19.76-linuxkit dask/dask#1 SMP Tue May 26 11:42:35 UTC 2020 x86_64 GNU/Linux
- Install method (conda, pip, source): pip

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.