aeth-ext 2.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
aeth_ext/__init__.py ADDED
@@ -0,0 +1,71 @@
1
+ # Standard library imports
2
+ from typing import TYPE_CHECKING, Literal, overload
3
+
4
+ # First party imports
5
+ from aeth_ext.monkey_patcher import MonkeyPatcher
6
+
7
+ # Local folder imports
8
+ from .logging.init import init_logging, init_logging_worker
9
+
10
+ if TYPE_CHECKING:
11
+ # Standard library imports
12
+ from collections.abc import Callable
13
+
14
+ # Local folder imports
15
+ from .logging.config import QueueCatchall
16
+
17
+ __all__ = ["initialize"]
18
+
19
+
20
+ @overload
21
+ def initialize(
22
+ *queues: QueueCatchall,
23
+ asyncio: bool = False,
24
+ worker: bool = False,
25
+ run_monkey_patches: bool = True,
26
+ return_wrapped: Literal[False] = False,
27
+ ) -> None: ...
28
+ @overload
29
+ def initialize(
30
+ *queues: QueueCatchall,
31
+ asyncio: bool = False,
32
+ worker: bool = False,
33
+ run_monkey_patches: bool = True,
34
+ return_wrapped: Literal[True],
35
+ ) -> Callable[[], None]: ...
36
+ def initialize(
37
+ *queues: QueueCatchall,
38
+ asyncio: bool = False,
39
+ worker: bool = False,
40
+ run_monkey_patches: bool = True,
41
+ return_wrapped: bool = False,
42
+ ) -> None | Callable[[], None]:
43
+ def wrapped_initialize() -> None:
44
+ if run_monkey_patches:
45
+ MonkeyPatcher.apply_monkey_patches()
46
+
47
+ if asyncio:
48
+ # Standard library imports
49
+ from sys import platform
50
+
51
+ if platform in ("win32", "cygwin", "cli"):
52
+ # Third party imports
53
+ from winloop import new_event_loop
54
+ else:
55
+ # if we're on apple or linux do this instead
56
+ # Third party imports
57
+ from uvloop import new_event_loop # type: ignore
58
+ # Standard library imports
59
+ from asyncio import set_event_loop
60
+
61
+ set_event_loop(new_event_loop())
62
+
63
+ if worker:
64
+ init_logging_worker(queues[0])
65
+ else:
66
+ init_logging(*queues)
67
+
68
+ if return_wrapped:
69
+ return wrapped_initialize
70
+
71
+ wrapped_initialize()