why-tools 0.2.1__tar.gz → 0.2.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.
- {why_tools-0.2.1 → why_tools-0.2.2}/PKG-INFO +1 -1
- {why_tools-0.2.1 → why_tools-0.2.2}/why_tools.egg-info/PKG-INFO +1 -1
- {why_tools-0.2.1 → why_tools-0.2.2}/why_tools.egg-info/SOURCES.txt +1 -0
- why_tools-0.2.2/ytools/VERSION +1 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/arq/client/base.py +13 -0
- why_tools-0.2.2/ytools/utils/host_ip.py +28 -0
- why_tools-0.2.1/ytools/VERSION +0 -1
- {why_tools-0.2.1 → why_tools-0.2.2}/README.md +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/setup.cfg +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/setup.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/why_tools.egg-info/dependency_links.txt +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/why_tools.egg-info/requires.txt +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/why_tools.egg-info/top_level.txt +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/__init__.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/arq/__init__.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/arq/client/__init__.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/arq/client/agent.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/arq/client/client.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/arq/setting.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/arq/task/__init__.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/arq/task/task.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/auto_driver/__init__.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/auto_driver/dp/__init__.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/auto_driver/dp/route.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/auto_driver/dp/route_by_fetch.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/auto_driver/dp/rpa.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/auto_driver/rpa_base.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/auto_driver/track.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/error.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/log.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/network/__init__.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/network/header.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/network/request.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/network/response.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/utils/__init__.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/utils/cache.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/utils/cache_utils.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/utils/date.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/utils/encrypt.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/utils/extractors.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/utils/file.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/utils/magic.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/utils/magic_for_class.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/utils/nodes.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/utils/package.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/utils/quiter.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/utils/sign.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/utils/track.py +0 -0
- {why_tools-0.2.1 → why_tools-0.2.2}/ytools/version.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.2.2
|
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
@Software: PyCharm
|
|
7
7
|
@Desc :
|
|
8
8
|
"""
|
|
9
|
+
import asyncio
|
|
10
|
+
import json
|
|
11
|
+
|
|
12
|
+
from ytools.utils.host_ip import get_local_ip
|
|
9
13
|
from ytools.utils.magic import require
|
|
10
14
|
|
|
11
15
|
require("redis")
|
|
@@ -27,11 +31,13 @@ class BaseClient:
|
|
|
27
31
|
queue_name=None,
|
|
28
32
|
redis=None
|
|
29
33
|
):
|
|
34
|
+
self.info = {}
|
|
30
35
|
self.set_queue(queue_name)
|
|
31
36
|
if isinstance(redis, dict):
|
|
32
37
|
self.redis = self.make_redis(**redis)
|
|
33
38
|
elif redis:
|
|
34
39
|
self.redis = redis
|
|
40
|
+
asyncio.create_task(self.heartbeat())
|
|
35
41
|
|
|
36
42
|
def set_queue(self, queue_name):
|
|
37
43
|
self.queue_name = queue_name or setting.DEFAULT_QUEUE_NAME
|
|
@@ -74,6 +80,13 @@ class BaseClient:
|
|
|
74
80
|
status_queue = self.get_queue(status_id, base=self.status_queue)
|
|
75
81
|
return await self.redis.delete(status_queue)
|
|
76
82
|
|
|
83
|
+
async def heartbeat(self):
|
|
84
|
+
h_key = self.get_queue(self.__class__.__name__.lower(), get_local_ip(), base=self.queue_name)
|
|
85
|
+
interval = 5
|
|
86
|
+
while True:
|
|
87
|
+
await self.redis.set(h_key, value=json.dumps(self.info), ex=interval + 1)
|
|
88
|
+
await asyncio.sleep(interval)
|
|
89
|
+
|
|
77
90
|
|
|
78
91
|
if __name__ == '__main__':
|
|
79
92
|
pass
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
@File : host_ip.py
|
|
4
|
+
@Author : yintian
|
|
5
|
+
@Date : 2025/11/5 14:21
|
|
6
|
+
@Software: PyCharm
|
|
7
|
+
@Desc :
|
|
8
|
+
"""
|
|
9
|
+
import socket
|
|
10
|
+
from functools import lru_cache
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@lru_cache()
|
|
14
|
+
def get_local_ip():
|
|
15
|
+
try:
|
|
16
|
+
# 创建一个socket对象并连接到外部地址
|
|
17
|
+
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
18
|
+
# 使用Google的DNS服务器地址,无需实际发送数据
|
|
19
|
+
s.connect(("8.8.8.8", 80))
|
|
20
|
+
local_ip = s.getsockname()[0]
|
|
21
|
+
s.close()
|
|
22
|
+
return local_ip
|
|
23
|
+
except Exception as e:
|
|
24
|
+
raise RuntimeError(f"无法获取内网IP: {str(e)}")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
if __name__ == '__main__':
|
|
28
|
+
pass
|
why_tools-0.2.1/ytools/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0.2.1
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|