diff --git a/dvc/lock.py b/dvc/lock.py index 27ca67229d..147118c0fe 100644 --- a/dvc/lock.py +++ b/dvc/lock.py @@ -15,6 +15,12 @@ DEFAULT_TIMEOUT = 5 +FAILED_TO_LOCK_MESSAGE = ( + "cannot perform the command because another DVC process seems to be " + "running on this project. If that is not the case, manually remove " + "`.dvc/lock` and try again." +) + class LockError(DvcException): """Thrown when unable to acquire the lock for dvc repo.""" @@ -71,10 +77,7 @@ def lock(self): try: super(Lock, self).lock(timedelta(seconds=DEFAULT_TIMEOUT)) except flufl.lock.TimeOutError: - raise LockError( - "cannot perform the cmd since DVC is busy and " - "locked. Please retry the cmd later." - ) + raise LockError(FAILED_TO_LOCK_MESSAGE) def _set_claimfile(self, pid=None): super(Lock, self)._set_claimfile(pid) @@ -119,10 +122,7 @@ def _do_lock(self): try: self._lock = zc.lockfile.LockFile(self.lockfile) except zc.lockfile.LockError: - raise LockError( - "cannot perform the cmd since DVC is busy and " - "locked. Please retry the cmd later." - ) + raise LockError(FAILED_TO_LOCK_MESSAGE) def lock(self): try: diff --git a/dvc/main.py b/dvc/main.py index b18117f792..660f9420d4 100644 --- a/dvc/main.py +++ b/dvc/main.py @@ -9,7 +9,6 @@ from dvc.exceptions import DvcParserError from dvc.exceptions import NotDvcRepoError from dvc.external_repo import clean_repos -from dvc.lock import LockError from dvc.logger import FOOTER from dvc.remote.pool import close_pools from dvc.utils.compat import is_py2 @@ -48,9 +47,6 @@ def main(argv=None): cmd = args.func(args) ret = cmd.run() - except LockError: - logger.exception("failed to lock before running a command") - ret = 250 except ConfigError: logger.exception("configuration error") ret = 251