dask / dask/distributed

Support creating a `ProcessInterface` without a running loop in 3.8 and 3.9

Open
#6,858 1 comment 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**:

dask-jobqueue creates a ProcessInterface as a test outside of a running event loop, this is supported on 3.10 thanks to the `asyncio.mixins._LoopBoundMixin`, this is not supported on 3.8 and 3.9 because asyncio.Lock and asyncio.Event call the deprecated `asyncio.get_event_loop()`

```
Python 3.9.13 | packaged by conda-forge | (main, May 27 2022, 16:56:21)
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from distributed.deploy.spec import ProcessInterface
>>> ProcessInterface()

>>> async def noop(): pass
...
>>> import asyncio
>>> asyncio.run(noop())
>>> ProcessInterface()
Traceback (most recent call last):
File "", line 1, in
File "/home/graingert/projects/distributed/distributed/deploy/spec.py", line 56, in __init__
self.lock = asyncio.Lock()
File "/home/graingert/anaconda3/envs/dask-distributed-39/lib/python3.9/asyncio/locks.py", line 81, in __init__
self._loop = events.get_event_loop()
File "/home/graingert/anaconda3/envs/dask-distributed-39/lib/python3.9/asyncio/events.py", line 642, in get_event_loop
raise RuntimeError('There is no current event loop in thread %r.'
RuntimeError: There is no current event loop in thread 'MainThread'.
>>>
```

**What you expected to happen**:

```
from distributed.deploy.spec import ProcessInterface
async def noop(): pass
ProcessInterface() # no deprecation warning
asyncio.run(noop)
ProcessInterface() # no deprecation warning
```

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

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.