Closed ThomasWaldmann closed 1 month ago
Repository
has a context manager that calls .close()
, so that should close the repo (if the context manager was used).
Looks good if it can acquire the lock:
(borg-env) tw@MacBook-Pro borg % borg with-lock python -c 'import time; time.sleep(100)'
>>> store opened
>>> repository locked
>>> repository opened
^CTraceback (most recent call last):
File "<string>", line 1, in <module>
KeyboardInterrupt
>>> repository unlocked
>>> store closed
>>> repository closed
But there is a bug if the lock can't be acquired:
(borg-env) tw@MacBook-Pro borg % borg repo-list
>>> store opened
Failed to create/acquire the lock <Store(url='file:///tmp/borg2test123', levels=[('archives/', [0]), ('config/', [0]), ('cache/', [0]), ('locks/', [0]), ('data/', [2]), ('keys/', [0])])> (timeout).
Note: no store closed
in this case.
https://github.com/borgbackup/borgstore/issues/54#issuecomment-2373742876
Update: the related PR fixed the hanging issue and will be released in borgstore 0.0.5.