satori-python-client 0.11.0__tar.gz → 0.11.2__tar.gz

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.
@@ -1,5 +1,5 @@
1
1
  includes = ["src/satori/client"]
2
- raw-dependencies = ["satori-python-core >= 0.11.0"]
2
+ raw-dependencies = ["satori-python-core >= 0.11.2"]
3
3
 
4
4
  [project]
5
5
  name = "satori-python-client"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: satori-python-client
3
- Version: 0.11.0
3
+ Version: 0.11.2
4
4
  Summary: Satori Protocol SDK for python, specify client part
5
5
  Home-page: https://github.com/RF-Tar-Railt/satori-python
6
6
  Author-Email: RF-Tar-Railt <rf_tar_railt@qq.com>
@@ -19,7 +19,7 @@ Project-URL: Repository, https://github.com/RF-Tar-Railt/satori-python
19
19
  Requires-Python: >=3.8
20
20
  Requires-Dist: aiohttp>=3.9.3
21
21
  Requires-Dist: launart>=0.8.2
22
- Requires-Dist: satori-python-core>=0.11.0
22
+ Requires-Dist: satori-python-core>=0.11.2
23
23
  Description-Content-Type: text/markdown
24
24
 
25
25
  # satori-python
@@ -7,7 +7,7 @@ authors = [
7
7
  dependencies = [
8
8
  "aiohttp>=3.9.3",
9
9
  "launart>=0.8.2",
10
- "satori-python-core >= 0.11.0",
10
+ "satori-python-core >= 0.11.2",
11
11
  ]
12
12
  description = "Satori Protocol SDK for python, specify client part"
13
13
  readme = "README.md"
@@ -23,7 +23,7 @@ classifiers = [
23
23
  "Programming Language :: Python :: 3.12",
24
24
  "Operating System :: OS Independent",
25
25
  ]
26
- version = "0.11.0"
26
+ version = "0.11.2"
27
27
 
28
28
  [project.license]
29
29
  text = "MIT"
@@ -1,7 +1,9 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import asyncio
4
+ import functools
4
5
  import signal
6
+ import threading
5
7
  from functools import wraps
6
8
  from typing import Any, Awaitable, Callable, Iterable, Literal, TypeVar, overload
7
9
 
@@ -211,8 +213,27 @@ class App(Service):
211
213
  manager.add_component(self)
212
214
  manager.launch_blocking(loop=loop, stop_signal=stop_signal)
213
215
 
214
- async def run_async(self, manager: Launart | None = None):
216
+ async def run_async(
217
+ self,
218
+ manager: Launart | None = None,
219
+ stop_signal: Iterable[signal.Signals] = (signal.SIGINT,),
220
+ ):
215
221
  if manager is None:
216
222
  manager = it(Launart)
217
223
  manager.add_component(self)
218
- await manager.launch()
224
+ handled_signals: dict[signal.Signals, Any] = {}
225
+ launch_task = asyncio.create_task(manager.launch(), name="amnesia-launch")
226
+ signal_handler = functools.partial(manager._on_sys_signal, main_task=launch_task)
227
+ if threading.current_thread() is threading.main_thread(): # pragma: worst case
228
+ try:
229
+ for sig in stop_signal:
230
+ handled_signals[sig] = signal.getsignal(sig)
231
+ signal.signal(sig, signal_handler)
232
+ except ValueError: # pragma: no cover
233
+ # `signal.signal` may throw if `threading.main_thread` does
234
+ # not support signals
235
+ handled_signals.clear()
236
+ await launch_task
237
+ for sig, handler in handled_signals.items():
238
+ if signal.getsignal(sig) is signal_handler:
239
+ signal.signal(sig, handler)