[PATCH 1 of 6] socketserver: backport a less sucky socketserver from python 3.5.1
Yuya Nishihara
yuya at tcha.org
Wed May 11 08:17:10 EDT 2016
On Mon, 9 May 2016 01:06:20 +0100, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1462472424 -3600
> # Thu May 05 19:20:24 2016 +0100
> # Node ID fff86624fbfa0c2e78bb2874d68e6dd191c371cd
> # Parent 57a24a85a2bc484cbd7c4b80959dc2d5f0483174
> socketserver: backport a less sucky socketserver from python 3.5.1
As I said before on IRC, I'm -1 for the backport. I'd rather resurrect a
simple socket server replacement only for commandserver.
Reasons:
It isn't difficult to write a simple fork-per-request server. I wouldn't
switch to SocketServer if I knew it is broken when I wrote the patch of
'unix' mode service, 840be5ca03e1.
> Consider the facts that:
>
> - We need to support Python 2.6 now
> - There are other users of SocketServer: commandserver, hgweb. hgweb can be
> affected by the Python 2.6 race condition if it uses the forking model.
> It is okay to re-invent the logic for chgserver alone but supporting all
> existing code is more complex and does not worth the efforts imo.
hgweb.server falls back to ForkingMixIn only if Python is compiled without
threading. I guess almost all users would use ThreadingMixIn.
> - There seems to be no existing solid, lightweight alternative to SocketServer.
> - The Python 3.5 socketserver module looks good enough on performance and
> feature set. We don't gain much re-inventing it and we may fall behind stdlib
> in the long run.
>
> It seems reasonable although suboptimal to do a backport now. This backport and
> its following changes will maintain API compatibility with Python's standard
> socketserver. Eventually when we only need to support Python >= 3.5, we can
> easily remove this file and just use Python's.
I expect chg will be switched to pre-forking server (or replaced by something
better than chg) when we're ready to drop Python 2.x compatibility.
More information about the Mercurial-devel
mailing list