Coverage for Lib/asyncio/__init__.py: 74%

40 statements  

« prev     ^ index     » next       coverage.py v7.10.4, created at 2025-08-23 01:21 +0000

1"""The asyncio package, tracking PEP 3156.""" 

2 

3# flake8: noqa 

4 

5import sys 

6 

7# This relies on each of the submodules having an __all__ variable. 

8from .base_events import * 

9from .coroutines import * 

10from .events import * 

11from .exceptions import * 

12from .futures import * 

13from .graph import * 

14from .locks import * 

15from .protocols import * 

16from .runners import * 

17from .queues import * 

18from .streams import * 

19from .subprocess import * 

20from .tasks import * 

21from .taskgroups import * 

22from .timeouts import * 

23from .threads import * 

24from .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 

44if sys.platform == 'win32': # pragma: no cover 

45 from .windows_events import * 

46 __all__ += windows_events.__all__ 

47else: 

48 from .unix_events import * # pragma: no cover 

49 __all__ += unix_events.__all__ 

50 

51def __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': 60 ↛ 61line 60 didn't jump to line 61 because the condition on line 60 was never true

61 return windows_events._DefaultEventLoopPolicy 

62 return unix_events._DefaultEventLoopPolicy 

63 case "WindowsSelectorEventLoopPolicy": 63 ↛ 64line 63 didn't jump to line 64 because the pattern on line 63 never matched

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": 68 ↛ 69line 68 didn't jump to line 69 because the pattern on line 68 never matched

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}")