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.
Files changed (49) hide show
  1. {why_tools-0.2.1 → why_tools-0.2.2}/PKG-INFO +1 -1
  2. {why_tools-0.2.1 → why_tools-0.2.2}/why_tools.egg-info/PKG-INFO +1 -1
  3. {why_tools-0.2.1 → why_tools-0.2.2}/why_tools.egg-info/SOURCES.txt +1 -0
  4. why_tools-0.2.2/ytools/VERSION +1 -0
  5. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/arq/client/base.py +13 -0
  6. why_tools-0.2.2/ytools/utils/host_ip.py +28 -0
  7. why_tools-0.2.1/ytools/VERSION +0 -1
  8. {why_tools-0.2.1 → why_tools-0.2.2}/README.md +0 -0
  9. {why_tools-0.2.1 → why_tools-0.2.2}/setup.cfg +0 -0
  10. {why_tools-0.2.1 → why_tools-0.2.2}/setup.py +0 -0
  11. {why_tools-0.2.1 → why_tools-0.2.2}/why_tools.egg-info/dependency_links.txt +0 -0
  12. {why_tools-0.2.1 → why_tools-0.2.2}/why_tools.egg-info/requires.txt +0 -0
  13. {why_tools-0.2.1 → why_tools-0.2.2}/why_tools.egg-info/top_level.txt +0 -0
  14. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/__init__.py +0 -0
  15. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/arq/__init__.py +0 -0
  16. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/arq/client/__init__.py +0 -0
  17. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/arq/client/agent.py +0 -0
  18. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/arq/client/client.py +0 -0
  19. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/arq/setting.py +0 -0
  20. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/arq/task/__init__.py +0 -0
  21. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/arq/task/task.py +0 -0
  22. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/auto_driver/__init__.py +0 -0
  23. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/auto_driver/dp/__init__.py +0 -0
  24. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/auto_driver/dp/route.py +0 -0
  25. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/auto_driver/dp/route_by_fetch.py +0 -0
  26. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/auto_driver/dp/rpa.py +0 -0
  27. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/auto_driver/rpa_base.py +0 -0
  28. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/auto_driver/track.py +0 -0
  29. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/error.py +0 -0
  30. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/log.py +0 -0
  31. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/network/__init__.py +0 -0
  32. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/network/header.py +0 -0
  33. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/network/request.py +0 -0
  34. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/network/response.py +0 -0
  35. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/utils/__init__.py +0 -0
  36. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/utils/cache.py +0 -0
  37. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/utils/cache_utils.py +0 -0
  38. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/utils/date.py +0 -0
  39. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/utils/encrypt.py +0 -0
  40. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/utils/extractors.py +0 -0
  41. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/utils/file.py +0 -0
  42. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/utils/magic.py +0 -0
  43. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/utils/magic_for_class.py +0 -0
  44. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/utils/nodes.py +0 -0
  45. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/utils/package.py +0 -0
  46. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/utils/quiter.py +0 -0
  47. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/utils/sign.py +0 -0
  48. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/utils/track.py +0 -0
  49. {why_tools-0.2.1 → why_tools-0.2.2}/ytools/version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: why-tools
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: 为什么还要使用别的工具呢?
5
5
  Home-page: https://github.com/yintian710/whytools
6
6
  Author: yintian
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: why-tools
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: 为什么还要使用别的工具呢?
5
5
  Home-page: https://github.com/yintian710/whytools
6
6
  Author: yintian
@@ -36,6 +36,7 @@ ytools/utils/date.py
36
36
  ytools/utils/encrypt.py
37
37
  ytools/utils/extractors.py
38
38
  ytools/utils/file.py
39
+ ytools/utils/host_ip.py
39
40
  ytools/utils/magic.py
40
41
  ytools/utils/magic_for_class.py
41
42
  ytools/utils/nodes.py
@@ -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
@@ -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