Patchwork D8024: profiling: flush stdout before writing profile to stderr

login
register
mail settings
Submitter phabricator
Date Jan. 29, 2020, 11:18 p.m.
Message ID <058e2636f5c95920da2863ac2a2ce0db@localhost.localdomain>
Download mbox | patch
Permalink /patch/44738/
State Not Applicable
Headers show

Comments

phabricator - Jan. 29, 2020, 11:18 p.m.
Closed by commit rHGd6d4170882cd: profiling: flush stdout before writing profile to stderr (authored by spectral).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8024?vs=19653&id=19678

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8024/new/

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

AFFECTED FILES
  mercurial/profiling.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/profiling.py b/mercurial/profiling.py
--- a/mercurial/profiling.py
+++ b/mercurial/profiling.py
@@ -186,6 +186,7 @@ 
         self._output = None
         self._fp = None
         self._fpdoclose = True
+        self._flushfp = None
         self._profiler = None
         self._enabled = enabled
         self._entered = False
@@ -246,6 +247,8 @@ 
             else:
                 self._fpdoclose = False
                 self._fp = self._ui.ferr
+                # Ensure we've flushed fout before writing to ferr.
+                self._flushfp = self._ui.fout
 
             if proffn is not None:
                 pass
@@ -265,6 +268,7 @@ 
     def __exit__(self, exception_type, exception_value, traceback):
         propagate = None
         if self._profiler is not None:
+            self._uiflush()
             propagate = self._profiler.__exit__(
                 exception_type, exception_value, traceback
             )
@@ -280,3 +284,7 @@ 
     def _closefp(self):
         if self._fpdoclose and self._fp is not None:
             self._fp.close()
+
+    def _uiflush(self):
+        if self._flushfp:
+            self._flushfp.flush()