File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 1
1
from __future__ import annotations
2
2
3
3
import os
4
+ import platform
4
5
from pathlib import Path
5
6
from typing import TYPE_CHECKING
6
7
26
27
from aerich .inspectdb import Inspect
27
28
28
29
30
+ def _init_asyncio_patch ():
31
+ """
32
+ Select compatible event loop for psycopg3.
33
+
34
+ As of Python 3.8+, the default event loop on Windows is `proactor`,
35
+ however psycopg3 requires the old default "selector" event loop.
36
+ See https://www.psycopg.org/psycopg3/docs/advanced/async.html
37
+ """
38
+ if platform .system () == "Windows" :
39
+ try :
40
+ from asyncio import WindowsSelectorEventLoopPolicy
41
+ except ImportError :
42
+ pass # Can't assign a policy which doesn't exist.
43
+ else :
44
+ from asyncio import get_event_loop_policy , set_event_loop_policy
45
+
46
+ if not isinstance (get_event_loop_policy (), WindowsSelectorEventLoopPolicy ):
47
+ set_event_loop_policy (WindowsSelectorEventLoopPolicy ())
48
+
49
+
50
+ _init_asyncio_patch ()
51
+
52
+
29
53
class Command :
30
54
def __init__ (
31
55
self ,
You can’t perform that action at this time.
0 commit comments