fix: Handle the case when error_handler returns Request#1595
Merged
Pijukatel merged 3 commits intoapify:masterfrom Dec 5, 2025
Merged
fix: Handle the case when error_handler returns Request#1595Pijukatel merged 3 commits intoapify:masterfrom
error_handler returns Request#1595Pijukatel merged 3 commits intoapify:masterfrom
Conversation
Collaborator
Author
|
I made a fix in accordance with the current signature for But the signature of |
Pijukatel
reviewed
Dec 4, 2025
Comment on lines
1140
to
1147
| await wait_for( | ||
| lambda: request_manager.mark_request_as_handled(request), | ||
| timeout=self._internal_timeout, | ||
| timeout_message='Marking request as handled timed out after ' | ||
| f'{self._internal_timeout.total_seconds()} seconds', | ||
| logger=self._logger, | ||
| max_retries=3, | ||
| ) |
Collaborator
There was a problem hiding this comment.
Now this is repeated 6x times in BasicCrawler in some variants. I would consider creating a utility function for it.
async def some_very_good_name(self, request: Request)->None:
request_manager = await self.get_request_manager()
await wait_for(
lambda: request_manager.mark_request_as_handled(request),
timeout=self._internal_timeout,
timeout_message='Marking request as handled timed out after '
f'{self._internal_timeout.total_seconds()} seconds',
logger=self._logger,
max_retries=3,
)
(no need to worry about request_manager = await self.get_request_manager(), it will resolve to self._request_manager)
Collaborator
There was a problem hiding this comment.
IMO we can use just a private method async def _mark_request_as_handled(self, request: Request) -> None:.
Co-authored-by: Josef Procházka <jos.prochazka@post.cz>
Pijukatel
approved these changes
Dec 5, 2025
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.
Description
crawlerwhenerror_handlerreturnsRequest. The old behavior resulted in the queue never reaching the empty state.Testing