Skip to main content

CRE-2025-0041

redis-py client fails with AttributeError when reused across async or process contextsLow
Impact: 5/10
Mitigation: 4/10

CRE-2025-0041View on GitHub

Description

- In redis-py v5.x, sharing a single Redis client across async tasks or subprocesses can result in:\n- `AttributeError: ''NoneType'' object has no attribute ''getpid''`.\n- This typically occurs when the client or connection pool is reused across forks or when event loop context is lost, especially in async frameworks or multiprocessing setups.\n

Mitigation

- Avoid sharing Redis clients across processes or async task groups.\n- Recreate clients inside subprocesses or use context-aware pools.\n- Use `redis.asyncio.ConnectionPool` directly if managing multiple workers manually.\n- Upgrade to the patched version of redis-py (see PR #3015).\n

References