No longer start stopped loops in LoopRunner to allow the use of asyncio.run
- Dominant language
- Python
- Stars
- 1.7k
- Forks
- 778
- Avg merge
- 2h 50m
- Merged PRs (30d)
- 3
Description
The `LoopRunner` is accepting an event loop that has been created externally. This is a pattern that has been deprecated by CPython and our current implementation.
## Requirements
- `LoopRunner` no longer accepts event loops but creates and owns them itself.
- There must still be a way to attach multiple servers (e.g. Scheduler and Client) to the same event loop.
- The `LoopRunner` guarantees that all existing `tornado.IOLoop` instances are properly closed if the underlying `asyncio` event loop is stopped when loop is started and stopped without tornado API (e.g. `asyncio.run`).
- It is not required to implement a deprecation cycle
More context in https://github.com/dask/distributed/issues/6049
## Implementation details
```python
# Current interface
class LoopRunner:
def __init__(self, loop=None, asynchronous=False):
...
def start(self):
...
def stop(self, timeout=10):
...
def run_sync(self, func, *args, **kwargs):
...
```
- [x] https://github.com/dask/distributed/pull/6443
- [x] https://github.com/dask/distributed/pull/6473
- [ ] https://github.com/dask/distributed/pull/6523
- [ ] Use loop_in_thread fixture for all tests that use local cluster, client, etc. to make sure they are using the correct event loop
- [ ] Deprecate passing a stopped loop to the LoopRunner
- [ ] Remove deprecated code after one to two release cycle
Contributor guide
Assessment
This issue has not been assessed yet.