Skip to content

Conversation

@eduards-vavere
Copy link

@eduards-vavere eduards-vavere commented Dec 18, 2025

Summary

  • Fix event loop blocking caused by time.sleep() in the rate limiting loop
  • Fix retry mechanism retry2 not supporting async functions
  • Remove retry2 and requests dependencies (unused/incompatible)

Related Issues

Fixes #89

Problem

The RequestExecutor.get() method had two issues causing problems in async environments (e.g., FastAPI):

  1. Blocking sleep: time.sleep(0.1) blocked the entire event loop during rate limiting
  2. Broken retry: retry_call() from retry2 returns a coroutine without awaiting it, causing retries to silently fail

Solution

Minimal fix replacing both with native asyncio equivalents:

  • time.sleep(0.1)await asyncio.sleep(0.1)
  • retry_call() → simple async for-loop with exponential backoff

Test plan

  • Unit tests pass (pytest tests/unit)
  • Integration tests (require Okta credentials)
  • Verify in async application (FastAPI/aiohttp) under load

- Replace time.sleep() with asyncio.sleep() in rate limiting loop
- Replace sync retry_call() with async-compatible retry loop
- Remove retry2 dependency (incompatible with async functions)
- Remove unused requests dependency
@eduards-vavere eduards-vavere changed the title Fix event loop blocking in async RequestExecutor (Fixes #89, Fixes #62) Fix event loop blocking in async RequestExecutor (Fixes #89) Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

High latency & Blocking behavior in RequestExecutor (Connection Pooling + time.sleep)

1 participant