-
Notifications
You must be signed in to change notification settings - Fork 0
Add thread-safety support (connection pooling) #15
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Description
IcapClient is not thread-safe. Multiple threads sharing a client instance could corrupt socket state.
Current Issues
- Socket interleaving if two threads call methods concurrently
- Check-then-act races in connection logic
- State corruption during disconnect
Implementation Options
- Lock-based (
threading.RLock) - Simple, serializes operations - Thread-local storage - Each thread gets own client
- Connection pool (
IcapClientPool) - Bounded resources, efficient reuse - Stateless - New socket per operation
Recommendation
Implement Option 1 (lock-based) as default for basic thread-safety, and provide Option 3 (connection pool) as IcapClientPool for high-throughput use cases.
Python Compatibility
All approaches work across Python 3.8-3.14. Note: Python 3.13+ free-threaded mode (PEP 703) makes explicit locking more critical.
Priority
Future enhancement - Not blocking release.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request