diff mercurial/util.py @ 36994:d683c7367989

wireproto: explicitly flush stdio to prevent stalls on Windows This is the key to fixing the hangs on Windows in D2720[1]. I put flushes in a bunch of other places that didn't help, but I suspect that's more a lack of test coverage than anything else. Chasing down stuff like this is pretty painful. I'm wondering if we can put a proxy around sys.stderr (and sys.stdout?) on Windows (only when daemonized?) that will flush on every write (or at least every write with a '\n'). [1] https://www.mercurial-scm.org/pipermail/mercurial-devel/2018-March/113352.html
author Matt Harbison <matt_harbison@yahoo.com>
date Sat, 10 Mar 2018 23:58:01 -0500
parents 644a02f6b34f
children 8453699a1f21
line wrap: on
line diff
--- a/mercurial/util.py	Sun Mar 18 15:32:49 2018 -0400
+++ b/mercurial/util.py	Sat Mar 10 23:58:01 2018 -0500
@@ -715,11 +715,13 @@
     def _writedata(self, data):
         if not self.logdata:
             self.fh.write('\n')
+            self.fh.flush()
             return
 
         # Simple case writes all data on a single line.
         if b'\n' not in data:
             self.fh.write(': %s\n' % escapedata(data))
+            self.fh.flush()
             return
 
         # Data with newlines is written to multiple lines.
@@ -727,6 +729,7 @@
         lines = data.splitlines(True)
         for line in lines:
             self.fh.write('%s>     %s\n' % (self.name, escapedata(line)))
+        self.fh.flush()
 
     def read(self, res, size=-1):
         if not self.reads: