From a31763afdeaec2f4cfd4b402e81692cd301b4c0a Mon Sep 17 00:00:00 2001 From: haosenwang1018 <1293965075@qq.com> Date: Sun, 15 Mar 2026 17:52:57 +0800 Subject: [PATCH 1/2] fix: replace bare raise with return False in _restore_from_checkpoint When _checkpoint_system_enabled is False, the method uses a bare `raise` with no active exception, which causes RuntimeError at runtime. The method's docstring says it returns False when restoration is not possible, so return False is the correct behavior. The caller in crawl() currently guards with `if self._checkpoint_system_enabled`, but the method's own contract should be self-consistent. Co-Authored-By: Claude Opus 4.6 (1M context) --- scrapling/spiders/engine.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scrapling/spiders/engine.py b/scrapling/spiders/engine.py index 416911d..d77f838 100644 --- a/scrapling/spiders/engine.py +++ b/scrapling/spiders/engine.py @@ -205,7 +205,7 @@ class CrawlerEngine: Returns True if successfully restored, False otherwise. """ if not self._checkpoint_system_enabled: - raise + return False data = await self._checkpoint_manager.load() if data is None: From cc6c0dbfb91c75b014634f4a3a70eb8bbb337c8b Mon Sep 17 00:00:00 2001 From: Karim shoair Date: Tue, 17 Mar 2026 17:46:47 +0200 Subject: [PATCH 2/2] fix: adjust test to the `_restore_from_checkpoint` fix --- tests/spiders/test_engine.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/spiders/test_engine.py b/tests/spiders/test_engine.py index ca768bf..b7bfd0f 100644 --- a/tests/spiders/test_engine.py +++ b/tests/spiders/test_engine.py @@ -613,8 +613,7 @@ class TestCheckpointMethods: @pytest.mark.asyncio async def test_restore_from_checkpoint_raises_when_disabled(self): engine = _make_engine() # no crawldir → checkpoint disabled - with pytest.raises(RuntimeError): - await engine._restore_from_checkpoint() + assert (await engine._restore_from_checkpoint()) is False # ---------------------------------------------------------------------------