WIP: Add locking of borgmatic config file #254
|
@ -1,9 +1,9 @@
|
|||
import collections
|
||||
import fcntl
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
import fcntl
|
||||
from subprocess import CalledProcessError
|
||||
|
||||
import colorama
|
||||
|
@ -55,7 +55,7 @@ def run_configuration(config_filename, config, arguments):
|
|||
encountered_error = None
|
||||
error_repository = ''
|
||||
|
||||
witten
commented
Given that this is in
... and then this would go through the rest of the borgmatic logging/error/summary machinery. Another option would be this:
Which would fall through and trigger the Given that this is in `run_configuration()` now, you can just:
```
except IOError as error:
yield from make_error_log_records(
'{}: Failed to acquire lock'.format(config_filename), error
)
return
```
... and then this would go through the rest of the borgmatic logging/error/summary machinery.
Another option would be this:
```
except IOError as error:
encountered_error = error
yield from make_error_log_records(
'{}: Failed to acquire lock'.format(config_filename), error
)
```
Which would fall through and trigger the `on_error` hook, if that's what you want to do in this case.
|
||||
if location.get("lock_client",False):
|
||||
if location.get("lock_client", False):
|
||||
witten
commented
Make sure you run tests with Make sure you run tests with `tox`, as the code formatter will probably complain about this. To have it reformat things for you: `tox -e black` is all you need to do.
|
||||
lock_f = open(config_filename)
|
||||
try:
|
||||
fcntl.flock(lock_f.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
|
|
Loading…
Reference in New Issue
tox -e isort
will order imports for you.