[Bug]: AsyncUrlSeeder.urls() always idles ~5 s after the last sitemap URL (worker polls queue.get() with a 5 s timeout)
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
Start in crawl4ai/async_url_seeder.py around the worker loop at line 486 and trace how producer completion and the max_urls early-stop path interact with the queue. Compare the same timeout pattern in extract_head_for_urls(). The issue suggests sentinels or waiting on both events; done means workers wake promptly after production ends without breaking early-stop behavior, with coverage for both paths.
索引モデルが issue の本文から書いたものです。
説明
crawl4ai version
0.9.4 (the same code is on main today)
Expected behavior
AsyncUrlSeeder.urls() returns as soon as the producer has yielded the last URL and the workers have processed the queue.
Current behavior
Every call takes about 5 seconds longer than reading the sitemap. In urls() each worker loops:
if queue.empty() and producer_done.is_set():
break
try:
url = await asyncio.wait_for(queue.get(), 5)
except asyncio.TimeoutError:
continue
(crawl4ai/async_url_seeder.py, line 486 on main.) A worker that finds the queue empty while the producer is still running parks in queue.get() with a 5 s timeout. When the producer then finishes without putting another item, nothing wakes that worker, so it sits out the full 5 s before it re-checks producer_done. With extract_head=False and live_check=False the workers do almost no work, so this wait is nearly the whole cost of the call.
In our crawler (sitemap source only, extract_head=False, concurrency=5) the wait was about 13 % of total crawl time per site across 23 real sites, and the first page started after 9.5 s instead of 6.1 s (median) once the wait was gone.
Steps to reproduce
import asyncio, time
from crawl4ai import AsyncUrlSeeder, SeedingConfig
async def main():
async with AsyncUrlSeeder() as seeder:
started = time.perf_counter()
urls = await seeder.urls("https://www.python.org", SeedingConfig(source="sitemap", extract_head=False, force=True))
print(len(urls), "URLs in", round(time.perf_counter() - started, 1), "s")
asyncio.run(main())
Timing the producer separately (iterating seeder._from_sitemaps(domain, "*", force=True)) shows the sitemap itself is read about 5 s faster than urls() returns.
Possible fix
Wake the workers when the producer finishes, for example with one sentinel per worker:
# producer, in its finally block
producer_done.set()
for _ in range(concurrency):
await queue.put(None)
# worker
url = await queue.get()
if url is None:
queue.task_done()
break
(The max_urls early-stop path that flushes the queue would need to keep the sentinels, or use asyncio.wait on queue.get() and producer_done.wait() instead of the polling timeout.) extract_head_for_urls() has the same pattern with a 1 s timeout.
OS
Linux (Debian, Docker), macOS
Python version
3.15
- 主要言語
- Python
- スター
- 87.2k
- フォーク
- 9.1k
- 平均マージ
- 1日 6時間
- マージ済み PR(30日)
- 25
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
unclecode/crawl4ai のほかの issue
-
BUG: UserAgentGenerator.generate ignores browser_type and returns a random browser stack対応中かも @HhH666-ux が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
[Bug]: Hardened docker-compose (read_only) keeps full Chromium from starting: crashpad needs a writable ~/.config対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン🐞 Bug 📌 Root caused
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
unclecode/crawl4ai#2494 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
⚙ Done ✨ Enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 1 日以内に返信
-
⚙ Done 🐞 Bug 📌 Root caused
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
[Bug]: PDF images saved with save_images_locally=True come back with an empty src in result.mediaオープン⚙ Done 🐞 Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
unclecode/crawl4ai#2469 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
unclecode/crawl4ai の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
Netcracker/qubership-ai-packages#266 ·
メンテナーはふだん 1 日以内に返信
-
PROCESSED_DATA_FOLDER: strip whitespace and treat empty as unset対応中かも @TorecLuik が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
NL-BioImaging/BIOMERO.importer#63 ·
メンテナーはふだん 1 日以内に返信
-
MLX training-complete chat/merge suggestions omit --backend mlx対応中かも @vaputa が今日担当しました。 オープンneeds-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
MakazhanAlpamys/Soup#2913 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area:security effort:S priority:P3 status:needs-triage type:chore
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
randomparity/kdive#3657 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
aws/mcp-proxy-for-aws#476 ·
メンテナーはふだん 1 日以内に返信