Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve LockError message #2765

Merged
merged 4 commits into from
Nov 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions dvc/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 0 additions & 4 deletions dvc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is about an error message only then why do we change the return code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@efiop might be able to answer this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Suor What will be the command on cmd on Windows? tasklist | findstr dvc?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LockError is based on DvcException and doesn't make it up here, as all CLI commands have try except DvcException in them. So we can remove this bit.

except ConfigError:
logger.exception("configuration error")
ret = 251
Expand Down