Merge pull request #2765 from algomaster99/improve-lock-error-message

Improve `LockError` message
This commit is contained in:
Ruslan Kuprieiev
2019-11-14 11:26:33 +02:00
committed by GitHub
2 changed files with 8 additions and 12 deletions
+8 -8
View File
@@ -15,6 +15,12 @@ from dvc.utils.compat import is_py3
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 @@ if is_py3:
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 @@ else:
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:
-4
View File
@@ -9,7 +9,6 @@ from dvc.config import ConfigError
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