mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 23:38:50 +03:00
dispatch: catch KeyboardInterrupt more broadly
Because _runcatch() can run long operations in its exception handler, it wasn't enough to catch KeyboardInterrupt at the same level. For example, "hg unknown" will load all extension modules, so we could easily make it crashed by Ctrl-C.
This commit is contained in:
parent
812fb817e3
commit
bd1b10fbe6
@ -120,11 +120,18 @@ def dispatch(req):
|
||||
ret = None
|
||||
try:
|
||||
ret = _runcatch(req)
|
||||
return ret
|
||||
except KeyboardInterrupt:
|
||||
try:
|
||||
req.ui.warn(_("interrupted!\n"))
|
||||
except IOError as inst:
|
||||
if inst.errno != errno.EPIPE:
|
||||
raise
|
||||
ret = -1
|
||||
finally:
|
||||
duration = time.time() - starttime
|
||||
req.ui.log("commandfinish", "%s exited %s after %0.2f seconds\n",
|
||||
msg, ret or 0, duration)
|
||||
return ret
|
||||
|
||||
def _runcatch(req):
|
||||
def catchterm(*args):
|
||||
@ -313,11 +320,7 @@ def _runcatch(req):
|
||||
else:
|
||||
ui.warn(_("abort: %s\n") % inst.strerror)
|
||||
except KeyboardInterrupt:
|
||||
try:
|
||||
ui.warn(_("interrupted!\n"))
|
||||
except IOError as inst:
|
||||
if inst.errno != errno.EPIPE:
|
||||
raise
|
||||
raise
|
||||
except MemoryError:
|
||||
ui.warn(_("abort: out of memory\n"))
|
||||
except SystemExit as inst:
|
||||
|
Loading…
Reference in New Issue
Block a user