| 1 |
"""The asyncio package, tracking PEP 3156.""" |
| 2 |
|
| 3 |
# flake8: noqa |
| 4 |
|
| 5 |
import sys |
| 6 |
|
| 7 |
# This relies on each of the submodules having an __all__ variable. |
| 8 |
from .base_events import * |
| 9 |
from .coroutines import * |
| 10 |
from .events import * |
| 11 |
from .exceptions import * |
| 12 |
from .futures import * |
| 13 |
from .graph import * |
| 14 |
from .locks import * |
| 15 |
from .protocols import * |
| 16 |
from .runners import * |
| 17 |
from .queues import * |
| 18 |
from .streams import * |
| 19 |
from .subprocess import * |
| 20 |
from .tasks import * |
| 21 |
from .taskgroups import * |
| 22 |
from .timeouts import * |
| 23 |
from .threads import * |
| 24 |
from .transports import * |
| 25 |
|
| 26 |
__all__ = (base_events.__all__ + |
| 27 |
coroutines.__all__ + |
| 28 |
events.__all__ + |
| 29 |
exceptions.__all__ + |
| 30 |
futures.__all__ + |
| 31 |
graph.__all__ + |
| 32 |
locks.__all__ + |
| 33 |
protocols.__all__ + |
| 34 |
runners.__all__ + |
| 35 |
queues.__all__ + |
| 36 |
streams.__all__ + |
| 37 |
subprocess.__all__ + |
| 38 |
tasks.__all__ + |
| 39 |
taskgroups.__all__ + |
| 40 |
threads.__all__ + |
| 41 |
timeouts.__all__ + |
| 42 |
transports.__all__) |
| 43 |
|
| 44 |
if sys.platform == 'win32': # pragma: no cover |
| 45 |
from .windows_events import * |
| 46 |
__all__ += windows_events.__all__ |
| 47 |
else: |
| 48 |
from .unix_events import * # pragma: no cover |
| 49 |
__all__ += unix_events.__all__ |
| 50 |
|
| 51 |
def __getattr__(name: str): |
| 52 |
import warnings |
| 53 |
|
| 54 |
match name: |
| 55 |
case "AbstractEventLoopPolicy": |
| 56 |
warnings._deprecated(f"asyncio.{name}", remove=(3, 16)) |
| 57 |
return events._AbstractEventLoopPolicy |
| 58 |
case "DefaultEventLoopPolicy": |
| 59 |
warnings._deprecated(f"asyncio.{name}", remove=(3, 16)) |
| 60 |
if sys.platform == 'win32': |
| 61 |
return windows_events._DefaultEventLoopPolicy |
| 62 |
return unix_events._DefaultEventLoopPolicy |
| 63 |
case "WindowsSelectorEventLoopPolicy": |
| 64 |
if sys.platform == 'win32': |
| 65 |
warnings._deprecated(f"asyncio.{name}", remove=(3, 16)) |
| 66 |
return windows_events._WindowsSelectorEventLoopPolicy |
| 67 |
# Else fall through to the AttributeError below. |
| 68 |
case "WindowsProactorEventLoopPolicy": |
| 69 |
if sys.platform == 'win32': |
| 70 |
warnings._deprecated(f"asyncio.{name}", remove=(3, 16)) |
| 71 |
return windows_events._WindowsProactorEventLoopPolicy |
| 72 |
# Else fall through to the AttributeError below. |
| 73 |
|
| 74 |
raise AttributeError(f"module {__name__!r} has no attribute {name!r}") |