Mercurial > hg-stable
changeset 37848:8c828beb7543 stable
lock: add internal config to not replace signal handlers while locking
signal.signal() is blocked in some WSGI environments, and a horrible warning
is sent to the server log. So we need a way to disable it, and I think
abusing ui.config is the simplest workaround.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Fri, 18 May 2018 21:24:06 +0900 |
parents | d46a38c07b1a |
children | 5b831053d9b6 |
files | mercurial/configitems.py mercurial/localrepo.py mercurial/lock.py |
diffstat | 3 files changed, 14 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/configitems.py Tue May 22 21:51:20 2018 -0400 +++ b/mercurial/configitems.py Fri May 18 21:24:06 2018 +0900 @@ -1127,6 +1127,9 @@ coreconfigitem('ui', 'rollback', default=True, ) +coreconfigitem('ui', 'signal-safe-lock', + default=True, +) coreconfigitem('ui', 'slash', default=False, )
--- a/mercurial/localrepo.py Tue May 22 21:51:20 2018 -0400 +++ b/mercurial/localrepo.py Fri May 18 21:24:06 2018 +0900 @@ -1693,12 +1693,15 @@ if wait: timeout = self.ui.configint("ui", "timeout") warntimeout = self.ui.configint("ui", "timeout.warn") + # internal config: ui.signal-safe-lock + signalsafe = self.ui.configbool('ui', 'signal-safe-lock') l = lockmod.trylock(self.ui, vfs, lockname, timeout, warntimeout, releasefn=releasefn, acquirefn=acquirefn, desc=desc, inheritchecker=inheritchecker, - parentlock=parentlock) + parentlock=parentlock, + signalsafe=signalsafe) return l def _afterlock(self, callback):
--- a/mercurial/lock.py Tue May 22 21:51:20 2018 -0400 +++ b/mercurial/lock.py Fri May 18 21:24:06 2018 +0900 @@ -21,6 +21,7 @@ encoding, error, pycompat, + util, ) from .utils import ( @@ -177,7 +178,7 @@ def __init__(self, vfs, fname, timeout=-1, releasefn=None, acquirefn=None, desc=None, inheritchecker=None, parentlock=None, - dolock=True): + signalsafe=True, dolock=True): self.vfs = vfs self.f = fname self.held = 0 @@ -189,6 +190,10 @@ self.parentlock = parentlock self._parentheld = False self._inherited = False + if signalsafe: + self._maybedelayedinterrupt = _delayedinterrupt + else: + self._maybedelayedinterrupt = util.nullcontextmanager self.postrelease = [] self.pid = self._getpid() if dolock: @@ -244,7 +249,7 @@ while not self.held and retry: retry -= 1 try: - with _delayedinterrupt(): + with self._maybedelayedinterrupt(): self.vfs.makelock(lockname, self.f) self.held = 1 except (OSError, IOError) as why: