summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/__init__.py29
-rw-r--r--Lib/asyncio/events.py8
-rw-r--r--Lib/asyncio/unix_events.py1
3 files changed, 23 insertions, 15 deletions
diff --git a/Lib/asyncio/__init__.py b/Lib/asyncio/__init__.py
index 4be7112..32a5dba 100644
--- a/Lib/asyncio/__init__.py
+++ b/Lib/asyncio/__init__.py
@@ -51,15 +51,24 @@ else:
def __getattr__(name: str):
import warnings
- deprecated = {
- "AbstractEventLoopPolicy",
- "DefaultEventLoopPolicy",
- "WindowsSelectorEventLoopPolicy",
- "WindowsProactorEventLoopPolicy",
- }
- if name in deprecated:
- warnings._deprecated(f"asyncio.{name}", remove=(3, 16))
- # deprecated things have underscores in front of them
- return globals()["_" + name]
+ match name:
+ case "AbstractEventLoopPolicy":
+ warnings._deprecated(f"asyncio.{name}", remove=(3, 16))
+ return events._AbstractEventLoopPolicy
+ case "DefaultEventLoopPolicy":
+ warnings._deprecated(f"asyncio.{name}", remove=(3, 16))
+ if sys.platform == 'win32':
+ return windows_events._DefaultEventLoopPolicy
+ return unix_events._DefaultEventLoopPolicy
+ case "WindowsSelectorEventLoopPolicy":
+ if sys.platform == 'win32':
+ warnings._deprecated(f"asyncio.{name}", remove=(3, 16))
+ return windows_events._WindowsSelectorEventLoopPolicy
+ # Else fall through to the AttributeError below.
+ case "WindowsProactorEventLoopPolicy":
+ if sys.platform == 'win32':
+ warnings._deprecated(f"asyncio.{name}", remove=(3, 16))
+ return windows_events._WindowsProactorEventLoopPolicy
+ # Else fall through to the AttributeError below.
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
diff --git a/Lib/asyncio/events.py b/Lib/asyncio/events.py
index 2913f90..a7fb559 100644
--- a/Lib/asyncio/events.py
+++ b/Lib/asyncio/events.py
@@ -5,14 +5,11 @@
# SPDX-FileCopyrightText: Copyright (c) 2015-2021 MagicStack Inc. http://magic.io
__all__ = (
- "_AbstractEventLoopPolicy",
"AbstractEventLoop",
"AbstractServer",
"Handle",
"TimerHandle",
- "_get_event_loop_policy",
"get_event_loop_policy",
- "_set_event_loop_policy",
"set_event_loop_policy",
"get_event_loop",
"set_event_loop",
@@ -791,7 +788,10 @@ def _init_event_loop_policy():
global _event_loop_policy
with _lock:
if _event_loop_policy is None: # pragma: no branch
- from . import _DefaultEventLoopPolicy
+ if sys.platform == 'win32':
+ from .windows_events import _DefaultEventLoopPolicy
+ else:
+ from .unix_events import _DefaultEventLoopPolicy
_event_loop_policy = _DefaultEventLoopPolicy()
diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py
index f69c6a6..1c14581 100644
--- a/Lib/asyncio/unix_events.py
+++ b/Lib/asyncio/unix_events.py
@@ -28,7 +28,6 @@ from .log import logger
__all__ = (
'SelectorEventLoop',
- '_DefaultEventLoopPolicy',
'EventLoop',
)