Mercurial > hg
diff mercurial/lock.py @ 38038: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 | 575f59cdd8a1 |
children | ead71b15efd5 |
line wrap: on
line diff
--- 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: