zenx 0.7.4__tar.gz → 0.7.8__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 (31) hide show
  1. {zenx-0.7.4 → zenx-0.7.8}/PKG-INFO +1 -1
  2. {zenx-0.7.4 → zenx-0.7.8}/pyproject.toml +1 -1
  3. {zenx-0.7.4 → zenx-0.7.8}/zenx/clients/database.py +2 -2
  4. {zenx-0.7.4 → zenx-0.7.8}/zenx/engine.py +1 -1
  5. {zenx-0.7.4 → zenx-0.7.8}/zenx/pipelines/google_rpc.py +1 -2
  6. {zenx-0.7.4 → zenx-0.7.8}/zenx/pipelines/websocket.py +1 -2
  7. {zenx-0.7.4 → zenx-0.7.8}/zenx/spiders/base.py +10 -2
  8. {zenx-0.7.4 → zenx-0.7.8}/zenx.egg-info/PKG-INFO +1 -1
  9. {zenx-0.7.4 → zenx-0.7.8}/setup.cfg +0 -0
  10. {zenx-0.7.4 → zenx-0.7.8}/zenx/cli.py +0 -0
  11. {zenx-0.7.4 → zenx-0.7.8}/zenx/clients/__init__.py +0 -0
  12. {zenx-0.7.4 → zenx-0.7.8}/zenx/clients/http.py +0 -0
  13. {zenx-0.7.4 → zenx-0.7.8}/zenx/debug_runner.py +0 -0
  14. {zenx-0.7.4 → zenx-0.7.8}/zenx/discovery.py +0 -0
  15. {zenx-0.7.4 → zenx-0.7.8}/zenx/exceptions.py +0 -0
  16. {zenx-0.7.4 → zenx-0.7.8}/zenx/logger.py +0 -0
  17. {zenx-0.7.4 → zenx-0.7.8}/zenx/pipelines/__init__.py +0 -0
  18. {zenx-0.7.4 → zenx-0.7.8}/zenx/pipelines/base.py +0 -0
  19. {zenx-0.7.4 → zenx-0.7.8}/zenx/pipelines/manager.py +0 -0
  20. {zenx-0.7.4 → zenx-0.7.8}/zenx/pipelines/preprocess.py +0 -0
  21. {zenx-0.7.4 → zenx-0.7.8}/zenx/resources/proto/__init__.py +0 -0
  22. {zenx-0.7.4 → zenx-0.7.8}/zenx/resources/proto/feed_pb2.py +0 -0
  23. {zenx-0.7.4 → zenx-0.7.8}/zenx/resources/proto/feed_pb2_grpc.py +0 -0
  24. {zenx-0.7.4 → zenx-0.7.8}/zenx/settings.py +0 -0
  25. {zenx-0.7.4 → zenx-0.7.8}/zenx/spiders/__init__.py +0 -0
  26. {zenx-0.7.4 → zenx-0.7.8}/zenx/utils.py +0 -0
  27. {zenx-0.7.4 → zenx-0.7.8}/zenx.egg-info/SOURCES.txt +0 -0
  28. {zenx-0.7.4 → zenx-0.7.8}/zenx.egg-info/dependency_links.txt +0 -0
  29. {zenx-0.7.4 → zenx-0.7.8}/zenx.egg-info/entry_points.txt +0 -0
  30. {zenx-0.7.4 → zenx-0.7.8}/zenx.egg-info/requires.txt +0 -0
  31. {zenx-0.7.4 → zenx-0.7.8}/zenx.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zenx
3
- Version: 0.7.4
3
+ Version: 0.7.8
4
4
  Summary: mini-framework
5
5
  Requires-Python: >=3.12
6
6
  Requires-Dist: curl-cffi>=0.12.0
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "zenx"
3
- version = "0.7.4"
3
+ version = "0.7.8"
4
4
  description = "mini-framework"
5
5
  requires-python = ">=3.12"
6
6
  dependencies = [
@@ -1,6 +1,5 @@
1
1
  from __future__ import annotations
2
2
  from abc import ABC, abstractmethod
3
- import time
4
3
  import collections
5
4
  from typing import ClassVar, Dict, List, Optional, Type
6
5
  from structlog import BoundLogger
@@ -113,7 +112,7 @@ try:
113
112
 
114
113
  async def _connect(self) -> None:
115
114
  self.logger.debug("connecting", db=self.name)
116
- self.r = redis.Redis(
115
+ pool = redis.ConnectionPool(
117
116
  host=self.settings.DB_HOST,
118
117
  port=self.settings.DB_PORT,
119
118
  password=self.settings.DB_PASS,
@@ -121,6 +120,7 @@ try:
121
120
  socket_connect_timeout=5,
122
121
  decode_responses=True,
123
122
  )
123
+ self.r = redis.Redis(connection_pool=pool)
124
124
  await self.r.ping()
125
125
  self.logger.info("connected", db=self.name)
126
126
 
@@ -66,7 +66,7 @@ class Engine:
66
66
 
67
67
 
68
68
  def run_spider(self, spider: str) -> None:
69
- asyncio.run(self._execute(spider))
69
+ uvloop.run(self._execute(spider))
70
70
 
71
71
 
72
72
  def run_spiders(self, spiders: List[str]) -> None:
@@ -51,8 +51,7 @@ try:
51
51
  await self._channel.wait_for_state_change(ready_state)
52
52
  try:
53
53
  await self._connect()
54
- except Exception as e:
55
- self.logger.error("reconnecting", exception=str(e), pipeline=self.name)
54
+ except Exception:
56
55
  await asyncio.sleep(0.5)
57
56
 
58
57
 
@@ -44,8 +44,7 @@ try:
44
44
  await self._ws_client.wait_closed()
45
45
  try:
46
46
  await self._connect()
47
- except Exception as e:
48
- self.logger.error("reconnecting", exception=str(e), pipeline=self.name)
47
+ except Exception:
49
48
  await asyncio.sleep(0.5)
50
49
 
51
50
 
@@ -1,6 +1,7 @@
1
1
  from __future__ import annotations
2
+ import asyncio
2
3
  from abc import ABC, abstractmethod
3
- from typing import ClassVar, Dict, List, Literal, Type
4
+ from typing import ClassVar, Coroutine, Dict, List, Literal, Type
4
5
  from structlog import BoundLogger
5
6
 
6
7
  from zenx.clients.http import HttpClient, Response
@@ -44,7 +45,14 @@ class Spider(ABC):
44
45
  self.pm = pm
45
46
  self.logger = logger
46
47
  self.settings = settings
47
-
48
+ self.background_tasks = set()
49
+
50
+
51
+ def create_task(self, coro: Coroutine) -> None:
52
+ t = asyncio.create_task(coro)
53
+ self.background_tasks.add(t)
54
+ t.add_done_callback(self.background_tasks.discard)
55
+
48
56
 
49
57
  @abstractmethod
50
58
  async def crawl(self) -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zenx
3
- Version: 0.7.4
3
+ Version: 0.7.8
4
4
  Summary: mini-framework
5
5
  Requires-Python: >=3.12
6
6
  Requires-Dist: curl-cffi>=0.12.0
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