intellif-aihub 0.1.0__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.

Potentially problematic release.


This version of intellif-aihub might be problematic. Click here for more details.

@@ -0,0 +1,6 @@
1
+ Metadata-Version: 2.4
2
+ Name: intellif-aihub
3
+ Version: 0.1.0
4
+ Summary: Graceful stop helper based on file sentinel
5
+ Author-email: Platform Team <aihub@example.com>
6
+ Requires-Python: >=3.7
@@ -0,0 +1,3 @@
1
+ from .stop import receive_stop_command, register_callback
2
+
3
+ __all__ = ["receive_stop_command", "register_callback"]
@@ -0,0 +1,36 @@
1
+ import os
2
+ import time
3
+ from pathlib import Path
4
+ from typing import Callable, List
5
+
6
+ _SENTINEL = Path(os.getenv("PRE_STOP_FILE", "/tmp/pre_stop"))
7
+ _flag = False # 缓存,防止反复读取 I/O
8
+ _callbacks: List[Callable[[], None]] = []
9
+
10
+
11
+ def _check_file() -> bool:
12
+ global _flag
13
+ if not _flag and _SENTINEL.exists():
14
+ _flag = True
15
+ for cb in _callbacks:
16
+ try:
17
+ cb()
18
+ except Exception as e:
19
+ print(f"[aihub] callback error: {e}", flush=True)
20
+ return _flag
21
+
22
+
23
+ def receive_stop_command() -> bool:
24
+ return _check_file()
25
+
26
+
27
+ def register_callback(func: Callable[[], None]) -> None:
28
+ _callbacks.append(func)
29
+ import threading
30
+ def _watch():
31
+ while True:
32
+ if _check_file():
33
+ break
34
+ time.sleep(1)
35
+
36
+ threading.Thread(target=_watch, daemon=True).start()
@@ -0,0 +1,6 @@
1
+ Metadata-Version: 2.4
2
+ Name: intellif-aihub
3
+ Version: 0.1.0
4
+ Summary: Graceful stop helper based on file sentinel
5
+ Author-email: Platform Team <aihub@example.com>
6
+ Requires-Python: >=3.7
@@ -0,0 +1,7 @@
1
+ pyproject.toml
2
+ aihub/__init__.py
3
+ aihub/stop.py
4
+ intellif_aihub.egg-info/PKG-INFO
5
+ intellif_aihub.egg-info/SOURCES.txt
6
+ intellif_aihub.egg-info/dependency_links.txt
7
+ intellif_aihub.egg-info/top_level.txt
@@ -0,0 +1,10 @@
1
+ [project]
2
+ name = "intellif-aihub"
3
+ version = "0.1.0"
4
+ requires-python = ">=3.7"
5
+ authors = [{name="Platform Team", email="aihub@example.com"}]
6
+ description = "Graceful stop helper based on file sentinel"
7
+
8
+ [build-system]
9
+ requires = ["setuptools>=61", "wheel"]
10
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+