rsloop 0.1.51__cp315-cp315-win_amd64.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.
rsloop/__init__.py ADDED
@@ -0,0 +1,27 @@
1
+ from __future__ import annotations
2
+
3
+ from ._bootstrap import bootstrap as __bootstrap
4
+
5
+ __bootstrap()
6
+
7
+ from ._loop_compat import (
8
+ Loop,
9
+ __version__,
10
+ build_info,
11
+ reset_transport_stats,
12
+ transport_stats,
13
+ )
14
+ from ._run import EventLoopPolicy, install, new_event_loop, run, uninstall
15
+
16
+ __all__: tuple[str, ...] = (
17
+ "EventLoopPolicy",
18
+ "Loop",
19
+ "__version__",
20
+ "build_info",
21
+ "install",
22
+ "new_event_loop",
23
+ "reset_transport_stats",
24
+ "run",
25
+ "transport_stats",
26
+ "uninstall",
27
+ )
rsloop/__init__.pyi ADDED
@@ -0,0 +1,40 @@
1
+ from asyncio import DefaultEventLoopPolicy
2
+ from collections.abc import Callable, Coroutine
3
+ from typing import Any, TypeVar
4
+
5
+ from ._loop import PyLoop
6
+
7
+ _T = TypeVar("_T")
8
+
9
+ Loop = PyLoop
10
+
11
+ __version__: str
12
+
13
+ def build_info() -> dict[str, str | bool]: ...
14
+ def transport_stats() -> dict[str, int | bool]: ...
15
+ def reset_transport_stats() -> None: ...
16
+
17
+ class EventLoopPolicy(DefaultEventLoopPolicy):
18
+ def new_event_loop(self) -> Loop: ...
19
+
20
+ def install() -> None: ...
21
+ def uninstall() -> None: ...
22
+ def new_event_loop() -> Loop: ...
23
+ def run(
24
+ main: Coroutine[Any, Any, _T],
25
+ *,
26
+ loop_factory: Callable[[], Loop] = ...,
27
+ debug: bool | None = ...,
28
+ ) -> _T: ...
29
+ __all__: tuple[str, ...] = (
30
+ "EventLoopPolicy",
31
+ "Loop",
32
+ "__version__",
33
+ "build_info",
34
+ "install",
35
+ "new_event_loop",
36
+ "reset_transport_stats",
37
+ "run",
38
+ "transport_stats",
39
+ "uninstall",
40
+ )
rsloop/_bootstrap.py ADDED
@@ -0,0 +1,112 @@
1
+ from __future__ import annotations
2
+
3
+ import os as __os
4
+ import ssl as __ssl
5
+ import sys as __sys
6
+ import typing as __typing
7
+
8
+ __DLL_DIR_HANDLES: list[object] = []
9
+
10
+
11
+ def configure_windows_dll_search_path() -> None:
12
+ if __sys.platform != "win32" or not hasattr(__os, "add_dll_directory"):
13
+ return
14
+
15
+ import shutil as __shutil
16
+
17
+ candidate_dirs: list[str] = []
18
+ gcc = __shutil.which("gcc")
19
+ if gcc is not None:
20
+ candidate_dirs.append(__os.path.dirname(gcc))
21
+
22
+ msys_prefix = __os.environ.get("MSYSTEM_PREFIX")
23
+ if msys_prefix:
24
+ candidate_dirs.append(__os.path.join(msys_prefix, "bin"))
25
+
26
+ candidate_dirs.extend(
27
+ [
28
+ r"C:\msys64\ucrt64\bin",
29
+ r"C:\msys64\mingw64\bin",
30
+ r"C:\msys64\clang64\bin",
31
+ ]
32
+ )
33
+
34
+ seen: set[str] = set()
35
+ for directory in candidate_dirs:
36
+ normalized = __os.path.normcase(__os.path.abspath(directory))
37
+ if normalized in seen or not __os.path.isdir(directory):
38
+ continue
39
+ if not __os.path.exists(__os.path.join(directory, "libstdc++-6.dll")):
40
+ continue
41
+ __DLL_DIR_HANDLES.append(__os.add_dll_directory(directory))
42
+ seen.add(normalized)
43
+
44
+
45
+ def install_ssl_tracking() -> None:
46
+ context_cls = __ssl.SSLContext
47
+ if getattr(context_cls, "_rsloop_tracking_installed", False):
48
+ return
49
+
50
+ def mark_default_verify_paths(context):
51
+ context.__dict__["_rsloop_use_default_verify_paths"] = True
52
+ return context
53
+
54
+ def mark_tls_config_changed(context):
55
+ state = context.__dict__
56
+ state["_rsloop_tls_generation"] = state.get("_rsloop_tls_generation", 0) + 1
57
+
58
+ orig_load_cert_chain = context_cls.load_cert_chain
59
+ orig_load_default_certs = context_cls.load_default_certs
60
+ orig_load_verify_locations = context_cls.load_verify_locations
61
+ orig_set_default_verify_paths = context_cls.set_default_verify_paths
62
+
63
+ def load_cert_chain(self, certfile, keyfile=None, password=None):
64
+ result = orig_load_cert_chain(
65
+ self,
66
+ certfile,
67
+ keyfile=keyfile,
68
+ password=password,
69
+ )
70
+ if callable(password):
71
+ password_value = password()
72
+ else:
73
+ password_value = password
74
+ if isinstance(password_value, str):
75
+ password_value = password_value.encode()
76
+ if password_value is not None and not isinstance(password_value, bytes):
77
+ password_value = bytes(__typing.cast(__typing.Any, password_value))
78
+ self.__dict__["_rsloop_certfile"] = __os.fspath(certfile)
79
+ self.__dict__["_rsloop_keyfile"] = (
80
+ __os.fspath(keyfile) if keyfile is not None else __os.fspath(certfile)
81
+ )
82
+ self.__dict__["_rsloop_key_password"] = password_value
83
+ mark_tls_config_changed(self)
84
+ return result
85
+
86
+ def load_default_certs(self, *args, **kwargs):
87
+ result = orig_load_default_certs(self, *args, **kwargs)
88
+ mark_default_verify_paths(self)
89
+ mark_tls_config_changed(self)
90
+ return result
91
+
92
+ def load_verify_locations(self, *args, **kwargs):
93
+ result = orig_load_verify_locations(self, *args, **kwargs)
94
+ mark_tls_config_changed(self)
95
+ return result
96
+
97
+ def set_default_verify_paths(self):
98
+ result = orig_set_default_verify_paths(self)
99
+ mark_default_verify_paths(self)
100
+ mark_tls_config_changed(self)
101
+ return result
102
+
103
+ context_cls.load_cert_chain = load_cert_chain
104
+ context_cls.load_default_certs = load_default_certs
105
+ context_cls.load_verify_locations = load_verify_locations
106
+ context_cls.set_default_verify_paths = set_default_verify_paths
107
+ __typing.cast(__typing.Any, context_cls)._rsloop_tracking_installed = True
108
+
109
+
110
+ def bootstrap() -> None:
111
+ configure_windows_dll_search_path()
112
+ install_ssl_tracking()
Binary file
rsloop/_loop.pyi ADDED
@@ -0,0 +1,53 @@
1
+ from asyncio import (
2
+ AbstractEventLoop,
3
+ Future,
4
+ Server,
5
+ StreamReader,
6
+ StreamWriter,
7
+ Task,
8
+ )
9
+ from collections.abc import Awaitable, Callable, Coroutine, Sequence
10
+ from contextvars import Context
11
+ from typing import Any, TypeVar
12
+
13
+ _T = TypeVar("_T")
14
+
15
+ __version__: str
16
+
17
+ def build_info() -> dict[str, str | bool]: ...
18
+ def transport_stats() -> dict[str, int | bool]: ...
19
+ def reset_transport_stats() -> None: ...
20
+
21
+ class PyLoop(AbstractEventLoop):
22
+ slow_callback_duration: float
23
+ def __init__(self) -> None: ...
24
+ def create_future(self) -> Future[Any]: ...
25
+ def create_task(
26
+ self,
27
+ coro: Coroutine[Any, Any, _T],
28
+ *,
29
+ name: object | None = None,
30
+ context: Context | None = None,
31
+ eager_start: bool | None = None,
32
+ **kwargs: Any,
33
+ ) -> Task[_T]: ...
34
+ def set_slow_callback_duration(self, value: float) -> None: ...
35
+
36
+ async def start_server(
37
+ client_connected_cb: Callable[[StreamReader, StreamWriter], Awaitable[None]]
38
+ | Callable[[StreamReader, StreamWriter], None],
39
+ host: str | Sequence[str] | None = None,
40
+ port: int | str | None = None,
41
+ *,
42
+ limit: int = 65536,
43
+ ssl_handshake_timeout: float | None = None,
44
+ **kwds: Any,
45
+ ) -> Server: ...
46
+ async def open_connection(
47
+ host: str | None = None,
48
+ port: int | str | None = None,
49
+ *,
50
+ limit: int = 65536,
51
+ ssl_handshake_timeout: float | None = None,
52
+ **kwds: Any,
53
+ ) -> tuple[StreamReader, StreamWriter]: ...