INNER CODE UNIT · Python

clamp_timespan_minutes

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

def clamp_timespan_minutes(value) -> int:
    try:
        minutes = int(value)
    except (TypeError, ValueError):
        minutes = _DEFAULT_TIMESPAN_MINUTES
    return max(_MIN_TIMESPAN_MINUTES, min(_MAX_TIMESPAN_MINUTES, minutes))


async def _respect_rate_limit() -> None:
    """Never issue a GDELT request less than 5s after the previous one."""
    global _last_request_at
    now = time.monotonic()
    wait = _MIN_REQUEST_INTERVAL_SECONDS - (now - _last_request_at)
    if wait > 0:
        await asyncio.sleep(wait)
    _last_request_at = time.monotonic()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…