-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Summary
ResponseCache in cache.py reads and writes JSON cache files without any file-level locking. In multi-process scenarios (common in network automation managing many devices), two processes could race on the same cache file, producing corrupt reads or lost writes.
Current Behavior
get()opens and reads JSON without lockingset()opens and writes JSON without locking- No
fcntl.flock()or equivalent mechanism
Impact
- Corrupt cache reads leading to
json.JSONDecodeError(caught, but cache miss) - Lost writes where one process overwrites another's cached response
- Unlikely but possible partial reads of in-progress writes
Suggested Fix
Consider using fcntl.flock() (Unix) or a cross-platform file locking library like filelock for atomic read/write operations on cache files. Alternatively, consider using an in-memory cache (like cachetools) with an optional persistence layer.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request