Skip to content

Commit a760446

Browse files
author
Vlad Stremousov
committed
Add warning about ProactorEventLoop incompatibility with async DB drivers on Windows
1 parent 6761b2c commit a760446

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

docs/concepts/event-loop.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,29 @@ When running with `--reload` or multiple workers, it uses [`SelectorEventLoop`][
1919
??? info "Why can `ProactorEventLoop` fail with multiple processes on Windows?"
2020
If you want to know more about it, you can read the issue [#cpython/122240](https://github.com/python/cpython/issues/122240).
2121

22+
!!! warning "`ProactorEventLoop` and async database drivers on Windows"
23+
[`ProactorEventLoop`][asyncio.ProactorEventLoop] does not support
24+
[`add_reader()`][asyncio.loop.add_reader] / [`add_writer()`][asyncio.loop.add_writer],
25+
which some async database drivers depend on — notably
26+
[psycopg](https://www.psycopg.org/psycopg3/docs/) and
27+
[asyncpg](https://github.com/MagicStack/asyncpg).
28+
29+
If you see errors like `Psycopg cannot use the 'ProactorEventLoop'`, switch to
30+
[`SelectorEventLoop`][asyncio.SelectorEventLoop] using the [custom event loop](#custom-event-loop)
31+
syntax:
32+
33+
```bash
34+
uvicorn main:app --loop asyncio:SelectorEventLoop
35+
```
36+
37+
Or set it once via the environment variable:
38+
39+
```bash
40+
set UVICORN_LOOP=asyncio:SelectorEventLoop
41+
```
42+
43+
See [#2749](https://github.com/Kludex/uvicorn/discussions/2749) for more details.
44+
2245
## Custom Event Loop
2346

2447
You can use custom event loop implementations by specifying a module path and function name using the colon notation:

0 commit comments

Comments
 (0)