changeset 39397:452790284a15

tracing: ignore any IOErrors when writing to pipe 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. Differential Revision: https://phab.mercurial-scm.org/D4445
author Augie Fackler <augie@google.com>
date Sat, 01 Sep 2018 11:33:17 -0400
parents f57682dca1c1
children 8ab79580047f
files hgdemandimport/tracing.py
diffstat 1 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgdemandimport/tracing.py	Sat Sep 01 11:06:47 2018 -0400
+++ b/hgdemandimport/tracing.py	Sat Sep 01 11:33:17 2018 -0400
@@ -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