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.
Files changed (33) hide show
  1. {zenx-0.10.1 → zenx-0.10.3}/PKG-INFO +1 -1
  2. {zenx-0.10.1 → zenx-0.10.3}/pyproject.toml +1 -1
  3. {zenx-0.10.1 → zenx-0.10.3}/zenx/engine.py +15 -2
  4. {zenx-0.10.1 → zenx-0.10.3}/zenx.egg-info/PKG-INFO +1 -1
  5. {zenx-0.10.1 → zenx-0.10.3}/README.md +0 -0
  6. {zenx-0.10.1 → zenx-0.10.3}/setup.cfg +0 -0
  7. {zenx-0.10.1 → zenx-0.10.3}/zenx/cli.py +0 -0
  8. {zenx-0.10.1 → zenx-0.10.3}/zenx/clients/__init__.py +0 -0
  9. {zenx-0.10.1 → zenx-0.10.3}/zenx/clients/database.py +0 -0
  10. {zenx-0.10.1 → zenx-0.10.3}/zenx/clients/http.py +0 -0
  11. {zenx-0.10.1 → zenx-0.10.3}/zenx/debug_runner.py +0 -0
  12. {zenx-0.10.1 → zenx-0.10.3}/zenx/discovery.py +0 -0
  13. {zenx-0.10.1 → zenx-0.10.3}/zenx/exceptions.py +0 -0
  14. {zenx-0.10.1 → zenx-0.10.3}/zenx/logger.py +0 -0
  15. {zenx-0.10.1 → zenx-0.10.3}/zenx/pipelines/__init__.py +0 -0
  16. {zenx-0.10.1 → zenx-0.10.3}/zenx/pipelines/base.py +0 -0
  17. {zenx-0.10.1 → zenx-0.10.3}/zenx/pipelines/discord.py +0 -0
  18. {zenx-0.10.1 → zenx-0.10.3}/zenx/pipelines/google_rpc.py +0 -0
  19. {zenx-0.10.1 → zenx-0.10.3}/zenx/pipelines/manager.py +0 -0
  20. {zenx-0.10.1 → zenx-0.10.3}/zenx/pipelines/preprocess.py +0 -0
  21. {zenx-0.10.1 → zenx-0.10.3}/zenx/pipelines/websocket.py +0 -0
  22. {zenx-0.10.1 → zenx-0.10.3}/zenx/resources/proto/__init__.py +0 -0
  23. {zenx-0.10.1 → zenx-0.10.3}/zenx/resources/proto/feed_pb2.py +0 -0
  24. {zenx-0.10.1 → zenx-0.10.3}/zenx/resources/proto/feed_pb2_grpc.py +0 -0
  25. {zenx-0.10.1 → zenx-0.10.3}/zenx/settings.py +0 -0
  26. {zenx-0.10.1 → zenx-0.10.3}/zenx/spiders/__init__.py +0 -0
  27. {zenx-0.10.1 → zenx-0.10.3}/zenx/spiders/base.py +0 -0
  28. {zenx-0.10.1 → zenx-0.10.3}/zenx/utils.py +0 -0
  29. {zenx-0.10.1 → zenx-0.10.3}/zenx.egg-info/SOURCES.txt +0 -0
  30. {zenx-0.10.1 → zenx-0.10.3}/zenx.egg-info/dependency_links.txt +0 -0
  31. {zenx-0.10.1 → zenx-0.10.3}/zenx.egg-info/entry_points.txt +0 -0
  32. {zenx-0.10.1 → zenx-0.10.3}/zenx.egg-info/requires.txt +0 -0
  33. {zenx-0.10.1 → zenx-0.10.3}/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.10.1
3
+ Version: 0.10.3
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.10.1"
3
+ version = "0.10.3"
4
4
  description = "mini-framework"
5
5
  requires-python = ">=3.12"
6
6
  dependencies = [
@@ -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
- await spider.crawl()
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()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zenx
3
- Version: 0.10.1
3
+ Version: 0.10.3
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
File without changes
File without changes
File without changes
File without changes