CRE-2025-0041
redis-py client fails with AttributeError when reused across async or process contextsLowImpact: 5/10Mitigation: 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: - `AttributeError: ''NoneType'' object has no attribute ''getpid''`. - 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.
Mitigation
- Avoid sharing Redis clients across processes or async task groups. - Recreate clients inside subprocesses or use context-aware pools. - Use `redis.asyncio.ConnectionPool` directly if managing multiple workers manually. - Upgrade to the patched version of redis-py (see PR #3015).