fix(scrapy): stop the crawl gracefully when the Actor run is migrated or aborted - #1104
Open
vdusek wants to merge 9 commits into
Open
fix(scrapy): stop the crawl gracefully when the Actor run is migrated or aborted#1104vdusek wants to merge 9 commits into
vdusek wants to merge 9 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1104 +/- ##
==========================================
+ Coverage 92.65% 92.83% +0.18%
==========================================
Files 51 53 +2
Lines 3445 3519 +74
==========================================
+ Hits 3192 3267 +75
+ Misses 253 252 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…plicate start page
…whether they were registered
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1103.
The Scrapy integration ignored
MIGRATINGandABORTING, so the process was killed with requests in flight. Those stay pending, the next run downloads them again, and their items land in the dataset twice.Why not
crawler.stop_async()for both eventswasMigrationInitiatedre-schedules it), so stopping the crawl onMIGRATINGwould lose the pending work.Migration
ApifySchedulerlistens forMIGRATING:next_request()hands out nothing, and the requests in flight are marked as handled as they finish.Actor.reboot()awaits the same listener, so a reboot waits for the requests in flight to settle first.Abort
ApifyGracefulStopExtension(registered byapply_apify_settings) callscrawler.stop_async()onABORTING.Docs and tests
Spider.start()yields withdont_filter=True, so a restarted run crawls the start URLs again. The example spider overridesstart()with plain requests.Actor.reboot()mid-crawl.✍️ Drafted by Claude Code