zenx 0.7.7__py3-none-any.whl → 0.7.8__py3-none-any.whl

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.
zenx/spiders/base.py CHANGED
@@ -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.7
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
@@ -19,9 +19,9 @@ zenx/resources/proto/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
19
19
  zenx/resources/proto/feed_pb2.py,sha256=ZyICOLnyuXekkvV4bAHZ1nE1-wwzcYYRRrmRJCMrSoo,2810
20
20
  zenx/resources/proto/feed_pb2_grpc.py,sha256=Mim6FfBgIMj0PmTqHk036nVUMJH3A6I3ts6r1j3bQF8,7441
21
21
  zenx/spiders/__init__.py,sha256=rs5LuqdM2MQlUYiTGJrzkYhzN8_SSLTrR7wGjSRrrSo,25
22
- zenx/spiders/base.py,sha256=YB-KqsAzfIUTzDMy5_ElgW1mul-I4Ltft6JAJxpy4hg,1672
23
- zenx-0.7.7.dist-info/METADATA,sha256=0KuilcBY8R3X--YL7rV_7FpLko_xlqv74ma6Ou0ZBKM,1273
24
- zenx-0.7.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
25
- zenx-0.7.7.dist-info/entry_points.txt,sha256=8JXob2f1VtvzGFris-e9Usqywg7oca-cChDlH9moOZU,38
26
- zenx-0.7.7.dist-info/top_level.txt,sha256=JeXwvK86d7sB-2x-avugFnZIZa33zaHWKI8RHWJR6KY,5
27
- zenx-0.7.7.dist-info/RECORD,,
22
+ zenx/spiders/base.py,sha256=BGxOvNnjaz6gmZm7NIgYc0RddWDmpIp53ukxprUUd-Y,1932
23
+ zenx-0.7.8.dist-info/METADATA,sha256=fFBAOhxqCQADIjLL9VP7Uc7O7Zg_f5_0tIbgaFXBKfg,1273
24
+ zenx-0.7.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
25
+ zenx-0.7.8.dist-info/entry_points.txt,sha256=8JXob2f1VtvzGFris-e9Usqywg7oca-cChDlH9moOZU,38
26
+ zenx-0.7.8.dist-info/top_level.txt,sha256=JeXwvK86d7sB-2x-avugFnZIZa33zaHWKI8RHWJR6KY,5
27
+ zenx-0.7.8.dist-info/RECORD,,
File without changes