diff --git a/CHANGES.txt b/CHANGES.txt index dfd9dce0..1c9c4b71 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,9 @@ +1.3.2b2 (2021-09-29) +^^^^^^^^^^^^^^^^^^^^ + +* Fix error NotImplemented for Windows OS and Python >= 3.8 `#881 `_ + + 1.3.2b1 (2021-07-11) ^^^^^^^^^^^^^^^^^^^^ diff --git a/aiopg/utils.py b/aiopg/utils.py index 86d66ccb..b6b5ef4d 100644 --- a/aiopg/utils.py +++ b/aiopg/utils.py @@ -14,7 +14,25 @@ Union, ) -if sys.version_info >= (3, 7, 0): + +def is_win_os() -> bool: + return sys.platform == 'win32' + + +class PythonVersion: + @staticmethod + def is_38_or_high() -> bool: + return sys.version_info >= (3, 8, 0) + + @staticmethod + def is_37_or_high() -> bool: + return sys.version_info >= (3, 7, 0) + + +if PythonVersion.is_38_or_high() and is_win_os(): + asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) + __get_running_loop = asyncio.get_running_loop +elif PythonVersion.is_37_or_high(): __get_running_loop = asyncio.get_running_loop else: