[PATCH 1 of 2] lock: loop a finite number of times in trylock (issue4787)
Matt Mackall
mpm at selenic.com
Mon Aug 24 22:13:00 UTC 2015
# HG changeset patch
# User Matt Mackall <mpm at selenic.com>
# Date 1440440683 18000
# Mon Aug 24 13:24:43 2015 -0500
# Node ID d7b7ac6570ada6329bbe777e40ec61287966eb57
# Parent 05e7f57c74ac5b556b49870af86f61aa0c54babb
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.
diff -r 05e7f57c74ac -r d7b7ac6570ad mercurial/lock.py
--- a/mercurial/lock.py Sat Aug 22 10:37:38 2015 -0700
+++ 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
More information about the Mercurial-devel
mailing list