zenx 0.10.1__tar.gz → 0.10.3__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.
- {zenx-0.10.1 → zenx-0.10.3}/PKG-INFO +1 -1
- {zenx-0.10.1 → zenx-0.10.3}/pyproject.toml +1 -1
- {zenx-0.10.1 → zenx-0.10.3}/zenx/engine.py +15 -2
- {zenx-0.10.1 → zenx-0.10.3}/zenx.egg-info/PKG-INFO +1 -1
- {zenx-0.10.1 → zenx-0.10.3}/README.md +0 -0
- {zenx-0.10.1 → zenx-0.10.3}/setup.cfg +0 -0
- {zenx-0.10.1 → zenx-0.10.3}/zenx/cli.py +0 -0
- {zenx-0.10.1 → zenx-0.10.3}/zenx/clients/__init__.py +0 -0
- {zenx-0.10.1 → zenx-0.10.3}/zenx/clients/database.py +0 -0
- {zenx-0.10.1 → zenx-0.10.3}/zenx/clients/http.py +0 -0
- {zenx-0.10.1 → zenx-0.10.3}/zenx/debug_runner.py +0 -0
- {zenx-0.10.1 → zenx-0.10.3}/zenx/discovery.py +0 -0
- {zenx-0.10.1 → zenx-0.10.3}/zenx/exceptions.py +0 -0
- {zenx-0.10.1 → zenx-0.10.3}/zenx/logger.py +0 -0
- {zenx-0.10.1 → zenx-0.10.3}/zenx/pipelines/__init__.py +0 -0
- {zenx-0.10.1 → zenx-0.10.3}/zenx/pipelines/base.py +0 -0
- {zenx-0.10.1 → zenx-0.10.3}/zenx/pipelines/discord.py +0 -0
- {zenx-0.10.1 → zenx-0.10.3}/zenx/pipelines/google_rpc.py +0 -0
- {zenx-0.10.1 → zenx-0.10.3}/zenx/pipelines/manager.py +0 -0
- {zenx-0.10.1 → zenx-0.10.3}/zenx/pipelines/preprocess.py +0 -0
- {zenx-0.10.1 → zenx-0.10.3}/zenx/pipelines/websocket.py +0 -0
- {zenx-0.10.1 → zenx-0.10.3}/zenx/resources/proto/__init__.py +0 -0
- {zenx-0.10.1 → zenx-0.10.3}/zenx/resources/proto/feed_pb2.py +0 -0
- {zenx-0.10.1 → zenx-0.10.3}/zenx/resources/proto/feed_pb2_grpc.py +0 -0
- {zenx-0.10.1 → zenx-0.10.3}/zenx/settings.py +0 -0
- {zenx-0.10.1 → zenx-0.10.3}/zenx/spiders/__init__.py +0 -0
- {zenx-0.10.1 → zenx-0.10.3}/zenx/spiders/base.py +0 -0
- {zenx-0.10.1 → zenx-0.10.3}/zenx/utils.py +0 -0
- {zenx-0.10.1 → zenx-0.10.3}/zenx.egg-info/SOURCES.txt +0 -0
- {zenx-0.10.1 → zenx-0.10.3}/zenx.egg-info/dependency_links.txt +0 -0
- {zenx-0.10.1 → zenx-0.10.3}/zenx.egg-info/entry_points.txt +0 -0
- {zenx-0.10.1 → zenx-0.10.3}/zenx.egg-info/requires.txt +0 -0
- {zenx-0.10.1 → zenx-0.10.3}/zenx.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
import asyncio
|
2
2
|
import signal
|
3
|
-
from typing import List
|
3
|
+
from typing import List, Optional
|
4
4
|
from dotenv import load_dotenv
|
5
5
|
import pebble
|
6
6
|
import uvloop
|
@@ -23,6 +23,7 @@ class Engine:
|
|
23
23
|
|
24
24
|
|
25
25
|
def _shutdown_handler(self) -> None:
|
26
|
+
print("signal catched")
|
26
27
|
self.shutdown_event.set()
|
27
28
|
|
28
29
|
|
@@ -47,6 +48,7 @@ class Engine:
|
|
47
48
|
await pm.start_pipelines()
|
48
49
|
|
49
50
|
spider = spider_cls(client=client, pm=pm, logger=logger, settings=settings)
|
51
|
+
crawl_task: Optional[asyncio.Task] = None
|
50
52
|
try:
|
51
53
|
if self.forever:
|
52
54
|
while not self.shutdown_event.is_set():
|
@@ -57,13 +59,24 @@ class Engine:
|
|
57
59
|
logger.exception("crawl")
|
58
60
|
await asyncio.sleep(0.01)
|
59
61
|
else:
|
60
|
-
|
62
|
+
crawl_task = asyncio.create_task(spider.crawl())
|
63
|
+
await crawl_task
|
61
64
|
finally:
|
65
|
+
print("closing...")
|
62
66
|
if self.shutdown_event.is_set():
|
63
67
|
logger.info("shutdown", spider=spider_name)
|
68
|
+
|
69
|
+
if crawl_task and not crawl_task.done():
|
70
|
+
crawl_task.cancel()
|
71
|
+
logger.debug("cancelled", task="crawl")
|
72
|
+
try:
|
73
|
+
await crawl_task
|
74
|
+
except asyncio.CancelledError:
|
75
|
+
pass
|
64
76
|
if spider.background_tasks:
|
65
77
|
logger.debug("waiting", background_tasks=len(spider.background_tasks), belong_to="spider")
|
66
78
|
await asyncio.gather(*spider.background_tasks)
|
79
|
+
|
67
80
|
await client.close()
|
68
81
|
await db.close()
|
69
82
|
await pm.close_pipelines()
|
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
|