Repository navigation
Conversation
|
|
||
| # Wait for the Playwright crawler to finish processing all requests | ||
| while not await playwright_rq.is_empty(): | ||
| while not isinstance(await playwright_rq.check_readiness(), FinishedStatus): |
There was a problem hiding this comment.
Oh, this is quite less convenient than how it worked before 😕.
There was a problem hiding this comment.
ok, then let's use literal comparison at least, so users aren't pushed into an extra import
| ```python | ||
| from crawlee.request_loaders import FinishedStatus, ReadyStatus | ||
|
|
||
| # v1 | ||
| has_requests = not await rq.is_empty() | ||
| done = await rq.is_finished() | ||
|
|
||
| # v2 | ||
| has_requests = isinstance(await rq.check_readiness(), ReadyStatus) | ||
| done = isinstance(await rq.check_readiness(), FinishedStatus) | ||
| ``` |
There was a problem hiding this comment.
As I mentioned above, this is much less convenient than before. You now need an additional import and an isinstance() check.
Maybe we could introduce helper methods for checking statuses, so determining whether an RQ is in a particular status would be a single method call?
There was a problem hiding this comment.
ok, then let's use literal comparison at least, so users aren't pushed into an extra import
There was a problem hiding this comment.
@janbuchar Have you considered keeping is_finished as a simple helper that wraps
isinstance(await rq.check_readiness(), FinishedStatus)?
We could add similar helpers for the other statuses where they make sense.
I mean, the new API is a bit worse in terms of ergonomics (maybe with AI agents it doesn't matter that much?).
There was a problem hiding this comment.
ok, then let's use literal comparison at least, so users aren't pushed into an extra import
Implemented in 883a68c
7a1ed98 to
3629140
Compare
3629140 to
a30518d
Compare
Description
RequestLoaderandRequestManagerreplaceis_empty()andis_finished()with a singlecheck_readiness(). It returns one of four statuses, exported fromcrawlee.request_loaders:ReadyStatus,WaitingStatus,StalledStatusorFinishedStatus.WaitingStatus.ready_atsays when a source expects to have work again, andThrottlingRequestManagersets it from its cooldowns.StalledStatus.reasonsays why a source can't make progress. Storage clients keepis_empty()andis_finished(). The upgrade guide covers the migration.ThrottlingRequestManager.get_stall_reason()is removed. The crawler reads a stall from the status, so it now also detects a stalled domain when theThrottlingRequestManageris wrapped in aRequestManagerTandem.RequestManagerTandemmoves a request from its loader only when the loader is ready, so aSitemapRequestLoaderthat's still loading sitemaps no longer holds up the requests already in the manager.RequestLoader.fetch_next_request()no longer has to wait for a request. ANonemeans nothing is pending right now, not that the loader is finished.SitemapRequestLoader.fetch_next_request()returnsNoneonce its sitemaps are loaded, instead of waiting until every fetched request is handled.Issues
is_empty/is_finishedwithcheck_readiness()and add pacing signals toRequestManager#2296✍️ Drafted by Claude Code