zenx 0.7.7__py3-none-any.whl → 0.7.9__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/engine.py +2 -0
- zenx/spiders/base.py +10 -2
- {zenx-0.7.7.dist-info → zenx-0.7.9.dist-info}/METADATA +1 -1
- {zenx-0.7.7.dist-info → zenx-0.7.9.dist-info}/RECORD +7 -7
- {zenx-0.7.7.dist-info → zenx-0.7.9.dist-info}/WHEEL +0 -0
- {zenx-0.7.7.dist-info → zenx-0.7.9.dist-info}/entry_points.txt +0 -0
- {zenx-0.7.7.dist-info → zenx-0.7.9.dist-info}/top_level.txt +0 -0
zenx/engine.py
CHANGED
@@ -60,6 +60,8 @@ class Engine:
|
|
60
60
|
finally:
|
61
61
|
if self.shutdown_event.is_set():
|
62
62
|
logger.info("shutdown", spider=spider_name)
|
63
|
+
if spider.background_tasks:
|
64
|
+
await asyncio.gather(*spider.background_tasks)
|
63
65
|
await client.close()
|
64
66
|
await db.close()
|
65
67
|
await pm.close_pipelines()
|
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,7 +1,7 @@
|
|
1
1
|
zenx/cli.py,sha256=pHKhOTdqI6NQQoYK91waRIMpxCXLYtXEryzVaTbmvqc,2810
|
2
2
|
zenx/debug_runner.py,sha256=B2Jd9A4_EHDa-ohLcwnFIxOV73FagTWXX2fl3qgwlpY,809
|
3
3
|
zenx/discovery.py,sha256=YANVGzy2IG1fYruUud-11Y-ynyO6iEp3EjlHnhIQJQI,1014
|
4
|
-
zenx/engine.py,sha256=
|
4
|
+
zenx/engine.py,sha256=XuPzQuDASkaEuxGFXU5ctntGMOyHitfxq0RgqT0sRmM,2444
|
5
5
|
zenx/exceptions.py,sha256=BJXxzwwX2CU6inhppfblx8c8Z6Mhvsk7MAhQ1LAnhBg,37
|
6
6
|
zenx/logger.py,sha256=UmEk0vV1mSCozV7z_DDgCCXdAManDr5wgkrhKiRQtyU,1651
|
7
7
|
zenx/settings.py,sha256=0RLeKcqHJdD1vuYIQtGeXkp2YIvv3tNyz9O8jw620VQ,1008
|
@@ -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=
|
23
|
-
zenx-0.7.
|
24
|
-
zenx-0.7.
|
25
|
-
zenx-0.7.
|
26
|
-
zenx-0.7.
|
27
|
-
zenx-0.7.
|
22
|
+
zenx/spiders/base.py,sha256=BGxOvNnjaz6gmZm7NIgYc0RddWDmpIp53ukxprUUd-Y,1932
|
23
|
+
zenx-0.7.9.dist-info/METADATA,sha256=orKA7TZTu6I7LK1o0txmKI4XDzckpy-JOhJ7HY4UFhg,1273
|
24
|
+
zenx-0.7.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
25
|
+
zenx-0.7.9.dist-info/entry_points.txt,sha256=8JXob2f1VtvzGFris-e9Usqywg7oca-cChDlH9moOZU,38
|
26
|
+
zenx-0.7.9.dist-info/top_level.txt,sha256=JeXwvK86d7sB-2x-avugFnZIZa33zaHWKI8RHWJR6KY,5
|
27
|
+
zenx-0.7.9.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|