# HG changeset patch # User Jun Wu <qu...@fb.com> # Date 1500089181 25200 # Fri Jul 14 20:26:21 2017 -0700 # Node ID a6545c15171810059596259f60574011184c3412 # Parent 5664763de82b48ca6882bbb624d01d467b4920d0 # Available At https://bitbucket.org/quark-zju/hg-draft # hg pull https://bitbucket.org/quark-zju/hg-draft -r a6545c151718 commandserver: use selector2
Previously, commandserver was using select.select. That could have issue if _sock.fileno() >= FD_SETSIZE (usually 1024), which raises: ValueError: filedescriptor out of range in select() We got that in production today, although it's the code opening that many files to blame, it seems better for commandserver to work in this case. There are multiple way to "solve" it, like preserving a fd with a small number and swap it with sock using dup2(). But upgrading to a modern selector supported by the system seems to be the most correct way. diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py --- a/mercurial/commandserver.py +++ b/mercurial/commandserver.py @@ -23,4 +23,5 @@ from . import ( error, pycompat, + selectors2, util, ) @@ -477,4 +478,6 @@ class unixforkingservice(object): exiting = False h = self._servicehandler + selector = selectors2.DefaultSelector() + selector.register(self._sock, selectors2.EVENT_READ) while True: if not exiting and h.shouldexit(): @@ -487,5 +490,5 @@ class unixforkingservice(object): exiting = True try: - ready = select.select([self._sock], [], [], h.pollinterval)[0] + ready = selector.select(timeout=h.pollinterval) if not ready: # only exit if we completed all queued requests _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel