Spaces:
Sleeping

File size: 500 Bytes
248a83c
6e5cdaf
248a83c
6e5cdaf
 
 
248a83c
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import httpx
import asyncio
from scraper.course_meta import fetch_course_meta, HEADERS

async def fetch_meta_batch(courses, limit=8):
    sem = asyncio.Semaphore(limit)
    
    async with httpx.AsyncClient(headers=HEADERS, timeout=10, follow_redirects=True) as client:
        async def safe(c):
            async with sem:
                meta = await fetch_course_meta(client, c["url"])
                return {**c, **meta}
        
        return await asyncio.gather(*[safe(c) for c in courses])