dwavesystems / dwavesystems/homebase
Handle possible race condition during directory create
- Dominant language
- Python
- Stars
- 5
- Forks
- 10
- PR merge metrics
- No merged PRs in 30d
Description
For all directory lookup operations when `create=True`, this gets executed in `_get_folder()`:
https://github.com/dwavesystems/homebase/blob/482e917aa003c7822c3d54378bbba5c6b2846450/homebase/homebase.py#L429-L430
Since directory existence check and create are not one atomic operation, it's possible directory gets created (by another thread or process running the same code) between the check and the create. When that happens, the other thread/process fails with `FileExistsError`.
The solution here is to set `exist_ok=True` when calling [`os.makedirs`](https://docs.python.org/3/library/os.html#os.makedirs). I.e. the create op should be idempotent here.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.