Mercurial > public > mercurial-scm > hg
diff tests/sshprotoext.py @ 51569:13c004b54cbe stable
wireprotoserver: ensure that output stream gets flushed on exception
Previously flush was happening due to Python finalizer being run on
`BufferedWriter`. With upgrade to Python 3.11 this started randomly
failing.
My guess is that the finalizer on the raw `FileIO` object may
be running before the finalizer of `BufferedWriter` has a chance to run.
At any rate, since we're not relying on finalizers in the happy case
we should also not rely on them in case of exception.
author | Arseniy Alekseyev <aalekseyev@janestreet.com> |
---|---|
date | Thu, 04 Apr 2024 14:15:32 +0100 |
parents | 6000f5b25c9b |
children | 5cc8deb96b48 |
line wrap: on
line diff
--- a/tests/sshprotoext.py Mon Apr 15 16:33:37 2024 +0100 +++ b/tests/sshprotoext.py Thu Apr 04 14:15:32 2024 +0100 @@ -30,7 +30,7 @@ def serve_forever(self): for i in range(10): - self._fout.write(b'banner: line %d\n' % i) + self._ui.fout.write(b'banner: line %d\n' % i) super(bannerserver, self).serve_forever() @@ -45,17 +45,16 @@ """ def serve_forever(self): - l = self._fin.readline() + ui = self._ui + l = ui.fin.readline() assert l == b'hello\n' # Respond to unknown commands with an empty reply. - wireprotoserver._sshv1respondbytes(self._fout, b'') - l = self._fin.readline() + wireprotoserver._sshv1respondbytes(ui.fout, b'') + l = ui.fin.readline() assert l == b'between\n' - proto = wireprotoserver.sshv1protocolhandler( - self._ui, self._fin, self._fout - ) + proto = wireprotoserver.sshv1protocolhandler(ui, ui.fin, ui.fout) rsp = wireprotov1server.dispatch(self._repo, proto, b'between') - wireprotoserver._sshv1respondbytes(self._fout, rsp.data) + wireprotoserver._sshv1respondbytes(ui.fout, rsp.data) super(prehelloserver, self).serve_forever()