D3716: ui: add an unsafeoperation context manager that can block SIGINT

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Sat Jun 16 16:07:21 EDT 2018


indygreg requested changes to this revision.
indygreg added a comment.
This revision now requires changes to proceed.


  I agree with @yuja that we should move this to `util.py` or one of its siblings and rename it to `uninterruptable` or some such.
  
  That being said, signal handlers are process global. And we do need to maintain persistent state so things don't get out of whack if we have overlapping calls, potentially from multiple threads (e.g. in the case of hgweb). So maybe `ui.py` - or even a global variable in that module - is the proper place for such state.
  
  Also, I wonder if we shouldn't delay signal handling instead of ignoring it. e.g. our new signal handler would print that the signal was received and then `raise KeyboardInterrupt` at context manager exit time. Otherwise, the handling of `SIGINT` is timing dependent and doesn't consistently result in an aborted process.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3716

To: durin42, #hg-reviewers, indygreg
Cc: indygreg, yuja, martinvonz, mercurial-devel


More information about the Mercurial-devel mailing list