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.
This PR removes the async lock from the crawlers and replaces it with a semaphore with a capacity of 20
In reality, neither the lock nor the semaphore are needed. The requests are actually limited by the
request_limiter
of each crawler, not the lock. However, i could not remove the lock because it will brake the logic for the UI scrape queue, that's why i replaced it with a semaphore instead.The lock was making each crawler behave synchronously and the
request_limiter
was never close to being reached. This was only for the crawlers. The downloaders have a semaphore already with a different capacity per domain, so they were not affected. The default capacity for each downloader is 3, defined by--max-simultaneous-downloads-per-domain
Disadvantages
The main drawback of replacing the lock with a semaphore (or eventually removing the lock altogether) is that the
request_limiter
is defined per crawler and almost all crawlers right now have a generic10 requests / sec
limit. Some crawlers may require fine tuning the limiter to make sure CDL does not trigger429s
The I/O to the requests cache will increase but that one is already overloaded in some cases. Needs a fix for the database lockups.