From 877e38551eca7b8d88155b4ae97dd1237c99b0d0 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Tue, 29 Oct 2019 20:54:56 +0200 Subject: [PATCH] lock: add a workaround for a flufl.lock bug (#2688) This bug doesn't affect us during regular dvc CLI commands, but is not visualy pleasing during API usage. Fixes #2573 --- dvc/lock.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/dvc/lock.py b/dvc/lock.py index 8859ff9e72..d3bc83d199 100644 --- a/dvc/lock.py +++ b/dvc/lock.py @@ -87,6 +87,17 @@ def _set_claimfile(self, pid=None): self._tmp_dir, filename + ".lock" ) + # Fix for __del__ bug in flufl.lock [1] which is causing errors on + # Python shutdown [2]. + # [1] https://gitlab.com/warsaw/flufl.lock/issues/7 + # [2] https://github.com/iterative/dvc/issues/2573 + def __del__(self): + try: + if self._owned: + self.finalize() + except ImportError: + pass + else: import zc.lockfile