[PATCH stable] py3: always flush ui streams on Python 3
Manuel Jacob
me at manueljacob.de
Wed Jun 3 04:14:45 UTC 2020
On 2020-06-03 05:46, Manuel Jacob wrote:
> On 2020-06-03 00:04, Augie Fackler wrote:
>>> On Jun 2, 2020, at 14:07, Manuel Jacob <me at manueljacob.de> wrote:
>>>
>>> # HG changeset patch
>>> # User Manuel Jacob <me at manueljacob.de>
>>> # Date 1591120869 -7200
>>> # Tue Jun 02 20:01:09 2020 +0200
>>> # Branch stable
>>> # Node ID ebbc45544673c33ea3beb887ed4d5230b015102a
>>> # Parent 91e509a12dbc4cd6cf2dcb9dae3ed383932132ac
>>> py3: always flush ui streams on Python 3
>>>
>>> On Python 2, we rely on that stdout and stderr are line buffered.
>>> Python 3’s
>>> io module doesn’t offer line buffered binary streams.
>>
>> We use the underlying non-buffer thing though for std{err, out}
>> though, or so I thought. Are you observing behavior that this
>> corrects?
>
> pycompat says:
>
> stdout = sys.stdout.buffer
> stderr = sys.stderr.buffer
>
> They are <_io.BufferedWriter name='<stdout>'> and <_io.BufferedWriter
> name='<stderr>'>, respectively.
>
> I observed the error in TortoiseHg, which is a long-running process.
>
> To trigger the problem with the hg command, you would need to do
> something slow that prints on `self._fout`, e.g. `hg pull
> https://www.mercurial-scm.org/repo/hg --debug`.
Actually, you don’t need to specify --debug.
Just run `hg pull https://www.mercurial-scm.org/repo/hg` and observe
that without the patch, "pulling from
https://www.mercurial-scm.org/repo/hg" will not be immediately printed
on your screen.
I’ve sent an updated patch with this example in the description and with
a correction.
More information about the Mercurial-devel
mailing list