mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2026-04-06 07:47:53 +10:00
bump versions
This commit is contained in:
@@ -17,6 +17,7 @@ from django.utils import timezone
|
||||
from rich.console import Console
|
||||
|
||||
from abx_dl.events import BinaryRequestEvent
|
||||
from abx_dl.heartbeat import CrawlHeartbeat
|
||||
from abx_dl.limits import CrawlLimitState
|
||||
from abx_dl.models import Plugin, discover_plugins, filter_plugins
|
||||
from abx_dl.orchestrator import (
|
||||
@@ -120,10 +121,16 @@ class CrawlRunner:
|
||||
self._live_stream = None
|
||||
|
||||
async def run(self) -> None:
|
||||
heartbeat = CrawlHeartbeat(
|
||||
Path(self.crawl.output_dir),
|
||||
runtime="archivebox",
|
||||
crawl_id=str(self.crawl.id),
|
||||
)
|
||||
try:
|
||||
snapshot_ids = await sync_to_async(self.load_run_state, thread_sensitive=True)()
|
||||
live_ui = self._create_live_ui()
|
||||
with live_ui if live_ui is not None else nullcontext():
|
||||
await heartbeat.start()
|
||||
setup_abx_services(
|
||||
self.bus,
|
||||
plugins=self.plugins,
|
||||
@@ -144,6 +151,7 @@ class CrawlRunner:
|
||||
await self.wait_for_snapshot_tasks()
|
||||
await self.run_crawl_cleanup(root_snapshot_id)
|
||||
finally:
|
||||
await heartbeat.stop()
|
||||
await self.bus.stop()
|
||||
if self._live_stream is not None:
|
||||
try:
|
||||
|
||||
@@ -608,17 +608,20 @@ def test_crawl_runner_calls_crawl_cleanup_after_snapshot_phase(monkeypatch):
|
||||
|
||||
|
||||
def test_abx_process_service_background_process_finishes_after_process_exit(monkeypatch, tmp_path):
|
||||
from abx_dl.models import Process as AbxProcess, now_iso
|
||||
from abx_dl.events import ProcessCompletedEvent, ProcessEvent
|
||||
from abx_dl.services.process_service import ProcessService
|
||||
from abx_dl.events import ProcessCompletedEvent, ProcessStartedEvent
|
||||
|
||||
service = object.__new__(ProcessService)
|
||||
service.emit_jsonl = False
|
||||
service.interactive_tty = False
|
||||
service.pause_requested = asyncio.Event()
|
||||
service.abort_requested = False
|
||||
emitted_events = []
|
||||
|
||||
class FakeBus:
|
||||
async def emit(self, event):
|
||||
emitted_events.append(event)
|
||||
return event
|
||||
|
||||
service.bus = FakeBus()
|
||||
|
||||
@@ -632,52 +635,28 @@ def test_abx_process_service_background_process_finishes_after_process_exit(monk
|
||||
|
||||
plugin_output_dir = tmp_path / "chrome"
|
||||
plugin_output_dir.mkdir()
|
||||
stdout_file = plugin_output_dir / "on_CrawlSetup__90_chrome_launch.daemon.bg.stdout.log"
|
||||
# stdout_file = plugin_output_dir / "on_CrawlSetup__90_chrome_launch.daemon.bg.stdout.log"
|
||||
stderr_file = plugin_output_dir / "on_CrawlSetup__90_chrome_launch.daemon.bg.stderr.log"
|
||||
stderr_file.write_text("")
|
||||
pid_file = plugin_output_dir / "on_CrawlSetup__90_chrome_launch.daemon.bg.pid"
|
||||
pid_file.write_text("12345")
|
||||
|
||||
proc = AbxProcess(
|
||||
cmd=["hook"],
|
||||
pwd=str(plugin_output_dir),
|
||||
timeout=60,
|
||||
started_at=now_iso(),
|
||||
plugin="chrome",
|
||||
hook_name="on_CrawlSetup__90_chrome_launch.daemon.bg",
|
||||
)
|
||||
|
||||
async def run_test():
|
||||
process = await asyncio.create_subprocess_exec(
|
||||
sys.executable,
|
||||
"-c",
|
||||
"pass",
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
stderr=asyncio.subprocess.PIPE,
|
||||
)
|
||||
event = ProcessStartedEvent(
|
||||
event = ProcessEvent(
|
||||
plugin_name="chrome",
|
||||
hook_name="on_CrawlSetup__90_chrome_launch.daemon.bg",
|
||||
hook_path="hook",
|
||||
hook_args=["--url=https://example.org/"],
|
||||
hook_path=sys.executable,
|
||||
hook_args=["-c", "pass"],
|
||||
env={},
|
||||
output_dir=str(plugin_output_dir),
|
||||
timeout=60,
|
||||
pid=process.pid,
|
||||
is_background=True,
|
||||
url="https://example.org/",
|
||||
process_type="hook",
|
||||
worker_type="hook",
|
||||
start_ts=proc.started_at or "",
|
||||
subprocess=process,
|
||||
stdout_file=stdout_file,
|
||||
stderr_file=stderr_file,
|
||||
pid_file=pid_file,
|
||||
cmd_file=plugin_output_dir / "on_CrawlSetup__90_chrome_launch.daemon.bg.sh",
|
||||
files_before=set(),
|
||||
)
|
||||
await asyncio.wait_for(
|
||||
service.on_ProcessStartedEvent(event),
|
||||
service.on_ProcessEvent(event),
|
||||
timeout=0.5,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user