|
66 | 66 |
|
67 | 67 |
|
68 | 68 | _logger = logging.getLogger(__name__)
|
| 69 | +cache_dir_lock: None | FileLock = None |
69 | 70 |
|
70 | 71 |
|
71 | 72 | class LintLogHandler(logging.Handler):
|
@@ -130,11 +131,12 @@ def initialize_options(arguments: list[str] | None = None) -> None:
|
130 | 131 | if options.cache_dir:
|
131 | 132 | options.cache_dir.mkdir(parents=True, exist_ok=True)
|
132 | 133 |
|
133 |
| - options.cache_dir_lock = None |
134 | 134 | if not options.offline: # pragma: no cover
|
135 |
| - options.cache_dir_lock = FileLock(f"{options.cache_dir}/.lock") |
| 135 | + cache_dir_lock = FileLock( # pylint: disable=redefined-outer-name |
| 136 | + f"{options.cache_dir}/.lock", |
| 137 | + ) |
136 | 138 | try:
|
137 |
| - options.cache_dir_lock.acquire(timeout=180) |
| 139 | + cache_dir_lock.acquire(timeout=180) |
138 | 140 | except Timeout: # pragma: no cover
|
139 | 141 | _logger.error(
|
140 | 142 | "Timeout waiting for another instance of ansible-lint to release the lock.",
|
@@ -294,9 +296,9 @@ def main(argv: list[str] | None = None) -> int:
|
294 | 296 | app.render_matches(result.matches)
|
295 | 297 |
|
296 | 298 | _perform_mockings_cleanup(app.options)
|
297 |
| - if options.cache_dir_lock: |
298 |
| - options.cache_dir_lock.release() |
299 |
| - pathlib.Path(options.cache_dir_lock.lock_file).unlink(missing_ok=True) |
| 299 | + if cache_dir_lock: |
| 300 | + cache_dir_lock.release() |
| 301 | + pathlib.Path(cache_dir_lock.lock_file).unlink(missing_ok=True) |
300 | 302 | if options.mock_filters:
|
301 | 303 | _logger.warning(
|
302 | 304 | "The following filters were mocked during the run: %s",
|
|
0 commit comments