INNER CODE UNIT · Python

wait

OpenOSINT/OpenOSINT · actors/news-monitor/src/main.py:69

    wait = _MIN_REQUEST_INTERVAL_SECONDS - (now - _last_request_at)
    if wait > 0:
        await asyncio.sleep(wait)
    _last_request_at = time.monotonic()


async def fetch_with_backoff(query: str, timespan_minutes: int) -> dict:
    """Fetch GDELT DOC data, retrying with backoff (longer after a 429)."""
    last_exc: Exception | None = None
    for attempt in range(_MAX_ATTEMPTS):
        await _respect_rate_limit()
        try:
            return await asyncio.to_thread(
                fetch_gdelt_doc_data,
                query,
                f"{timespan_minutes}min",
                _MAXRECORDS,
                _REQUEST_TIMEOUT_SECONDS,

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…