mirror of
https://github.com/nethunterzist/trendyol-analiz
synced 2026-07-01 01:17:04 +00:00
fix: SSE timeout during social proof collection
Ne yaptık: - time.sleep() → await asyncio.sleep() ile event loop bloklanması engellendi - Sosyal kanıt batch size 5 → 20 (1115 istek → 279 istek, %75 azalma) - SSE keepalive heartbeat eklendi (her 10 batch'te bir) - Nginx proxy timeout 180s → 600s (10 dakika) - Rate limit sleep süreleri optimize edildi (2s→1.5s, 0.5s→0.3s) Neden yaptık: - Kadın kategorisi gibi büyük raporlarda (82 yaprak kategori, 5576 ürün) sosyal kanıt aşamasında SSE bağlantısı kopuyordu. Kök neden: senkron time.sleep() async generator içinde event loop'u blokluyor, proxy idle timeout'a takılıyor ve bağlantıyı kesiyordu. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1567,8 +1567,8 @@ async def create_report(
|
||||
yield f"data: {json_module.dumps({'type': 'error', 'message': f'❌ {cat_name} - Hata: {str(e)}', 'progress': progress})}\n\n"
|
||||
await asyncio.sleep(0.1)
|
||||
|
||||
# Rate limiting
|
||||
time.sleep(2.0)
|
||||
# Rate limiting (non-blocking)
|
||||
await asyncio.sleep(1.5)
|
||||
|
||||
# ============================================
|
||||
# Sosyal Kanıt Verilerini Topla
|
||||
@@ -1630,7 +1630,7 @@ async def create_report(
|
||||
social_proof_data = {}
|
||||
total_products = len(all_product_ids)
|
||||
processed = 0
|
||||
batch_size = 5
|
||||
batch_size = 20
|
||||
|
||||
# print(f"🔍 DEBUG: Toplam {total_products} ürün ID'si toplandı")
|
||||
# print(f"🔍 DEBUG: İlk 5 ürün ID'si: {all_product_ids[:5] if all_product_ids else 'YOK'}")
|
||||
@@ -1677,8 +1677,10 @@ async def create_report(
|
||||
processed += len(chunk)
|
||||
progress_pct = int((processed / total_products) * 5) + 85 # 85-90%
|
||||
yield f"data: {json_module.dumps({'type': 'info', 'message': f'📊 Sosyal kanıt: {processed}/{total_products} ürün', 'progress': progress_pct})}\n\n"
|
||||
await asyncio.sleep(0.02)
|
||||
time.sleep(0.5) # Rate limiting
|
||||
# SSE keepalive heartbeat every 10 batches
|
||||
if processed % (batch_size * 10) == 0:
|
||||
yield f": heartbeat\n\n"
|
||||
await asyncio.sleep(0.3) # Rate limiting (non-blocking)
|
||||
|
||||
# print(f"✅ DEBUG: Sosyal kanıt toplama tamamlandı. Toplanan veri: {len(social_proof_data)} ürün")
|
||||
yield f"data: {json_module.dumps({'type': 'success', 'message': f'✅ Sosyal kanıt verileri toplandı ({len(social_proof_data)} ürün)', 'progress': 90})}\n\n"
|
||||
|
||||
Reference in New Issue
Block a user