[PATCH 02 of 11 V2] procutil: ensure that all stdio file objects are flushed at interpreter exit
Yuya Nishihara
yuya at tcha.org
Tue Jul 14 09:54:48 UTC 2020
On Mon, 13 Jul 2020 17:14:31 +0200, Manuel Jacob wrote:
> > Didn't we agree that the use of atexit wouldn't buy and we'll instead
> > add
> > py3-only solution later?
> >
> > As I said, atexit will increase the complexity of the control flow. All
> > data
> > should be flushed inside dispatch.run().
>
> We talked past each other, then. What I meant is that for stderr it’s
> not worth it because 1) we have other reasons to back it out, 2) stderr
> may be used for tracebacks etc. even after the atexit hook. For stdout
> it’s not as important because stdout is mostly written to through the ui
> object, but still there are some contrib scripts etc. using it directly.
I see. I meant the use of atexit isn't nice at all. Sorry for confusion.
> I don’t see any problem using atexit for this particular use case, but
> since I didn’t invest further time trying to find a case where we need
> it for stdout (and the stderr problem was solved otherwise), I’d be fine
> dropping the patch. On Python 3, we don’t need to do anything. What do
> you think?
I prefer dropping this patch.
Historically we've replaced atexit() with custom ui.atexit() function for
better control of errors and execution flow, see c13ff31818b0. I don't
remember the exact problem, but doing I/O in atexit() would be undesired.
More information about the Mercurial-devel
mailing list