|
8 | 8 | import warnings |
9 | 9 |
|
10 | 10 | import click |
11 | | -from lockfile import LockTimeout |
12 | | -from lockfile.pidlockfile import PIDLockFile |
| 11 | +from filelock import FileLock, Timeout |
13 | 12 |
|
14 | 13 | from bugwarrior.collect import aggregate_issues |
15 | 14 | from bugwarrior.config import get_config_path, get_keyring, load_config |
@@ -123,21 +122,17 @@ def pull( |
123 | 122 | config = _try_load_config(main_section, quiet) |
124 | 123 |
|
125 | 124 | lockfile_path = os.path.join(config.main.data.path, 'bugwarrior.lockfile') |
126 | | - lockfile = PIDLockFile(lockfile_path) |
127 | | - lockfile.acquire(timeout=10) |
128 | | - try: |
| 125 | + with FileLock(lockfile_path, timeout=10): |
129 | 126 | # Get all the issues. This can take a while. |
130 | 127 | issue_generator = aggregate_issues(config, debug) |
131 | 128 |
|
132 | 129 | # Stuff them in the taskwarrior db as necessary |
133 | 130 | synchronize(issue_generator, config, dry_run) |
134 | | - finally: |
135 | | - lockfile.release() |
136 | | - except LockTimeout: |
| 131 | + except Timeout: |
137 | 132 | log.critical( |
138 | 133 | 'Your taskrc repository is currently locked. ' |
139 | | - 'Remove the file at %s if you are sure no other ' |
140 | | - 'bugwarrior processes are currently running.' % (lockfile_path) |
| 134 | + 'Wait for any running bugwarrior processes to finish and try again. ' |
| 135 | + f'Lock file:{lockfile_path}' |
141 | 136 | ) |
142 | 137 | sys.exit(1) |
143 | 138 | except RuntimeError as e: |
|
0 commit comments