Mercurial > hg-stable
changeset 26081:3b6e5914edd8
lock: loop a finite number of times in trylock (issue4787)
..before falling back to lock, which will sleep. This only addresses
the CPU consumption of the reported issue.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 24 Aug 2015 13:24:43 -0500 |
parents | 83c9edcac05c |
children | b188f60bd955 |
files | mercurial/lock.py |
diffstat | 1 files changed, 3 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/lock.py Fri Aug 14 12:25:14 2015 +0900 +++ b/mercurial/lock.py Mon Aug 24 13:24:43 2015 -0500 @@ -83,7 +83,9 @@ if lock._host is None: lock._host = socket.gethostname() lockname = '%s:%s' % (lock._host, self.pid) - while not self.held: + retry = 5 + while not self.held and retry: + retry -= 1 try: self.vfs.makelock(lockname, self.f) self.held = 1