D4445: tracing: ignore any IOErrors when writing to pipe

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Sat Sep 1 15:33:32 UTC 2018


durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  When the pager forks off the main process, we can end up with the pipe
  closed prematurely. Rather than break hg entirely when that happens
  and tracing is active, just let lingering events disappear as needed.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgdemandimport/tracing.py

CHANGE DETAILS

diff --git a/hgdemandimport/tracing.py b/hgdemandimport/tracing.py
--- a/hgdemandimport/tracing.py
+++ b/hgdemandimport/tracing.py
@@ -28,7 +28,17 @@
         _session = os.environ.get('HGCATAPULTSESSION', 'none')
     whence = whencefmt % whenceargs
     try:
-        _pipe.write('START %s %s\n' % (_session, whence))
+        # Both writes to the pipe are wrapped in try/except to ignore
+        # errors, as we can see mysterious errors in here if the pager
+        # is active. Presumably other conditions could trigger
+        # problems too.
+        try:
+            _pipe.write('START %s %s\n' % (_session, whence))
+        except IOError:
+            pass
         yield
     finally:
-        _pipe.write('END %s %s\n' % (_session, whence))
+        try:
+            _pipe.write('END %s %s\n' % (_session, whence))
+        except IOError:
+            pass



To: durin42, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list