fix(scrapy): async-thread shutdown, duplicate error logs, and timeout setting#980
Draft
vdusek wants to merge 3 commits into
Draft
fix(scrapy): async-thread shutdown, duplicate error logs, and timeout setting#980vdusek wants to merge 3 commits into
vdusek wants to merge 3 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #980 +/- ##
==========================================
+ Coverage 89.90% 91.01% +1.10%
==========================================
Files 49 49
Lines 3091 3116 +25
==========================================
+ Hits 2779 2836 +57
+ Misses 312 280 -32
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:
|
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.
Fixes several smaller defects in the Scrapy integration's background event-loop thread, scheduler, and HTTP cache storage.
ApifyCacheStorage.close_spider, the expiration sweep ran outside thetry, so a failure there skippedAsyncThread.close(). The sweep now runs insidetry, withclose()in afinallyso it always runs.AsyncThread.close()raised on a second call. A repeated close (e.g.ApifyScheduler.open()closing on failure, then Scrapy closing again) called into the already-closed loop and raisedRuntimeError: Event loop is closed. Added anis_closed()early-return guard so a second close is a no-op.AsyncThread.close()ignored itstimeoutargument for the task-cancellation step (it used the constructor default). It now passes the caller'stimeoutto that step too.run_corotimeout left the coroutine running. On timeout it now cancels the future so the coroutine does not outlive the timeout.run_corologged-and-raised and each scheduler call addedtraceback.print_exc()(which bypassesActorLogFormatter), on top of Scrapy's own logging. Removed the redundanttraceback.print_exc()wrappers andrun_coro's log-and-raise; errors now surface once, formatted, via Scrapy.APIFY_ASYNC_THREAD_TIMEOUT_SECSScrapy setting, wired into the scheduler (viafrom_crawler) and the cache storage so theAsyncThreadtimeout is actually configurable.Adds unit tests for each fix (new
tests/unit/scrapy/test_async_thread.pyplus additions to the scheduler and HTTP cache test modules).