Patchwork [V2] commandserver: do not handle EINTR for selector.select

login
register
mail settings
Submitter Jun Wu
Date July 16, 2017, 6:23 p.m.
Message ID <3fce51f52763323f1ff2.1500229420@x1c>
Download mbox | patch
Permalink /patch/22442/
State Accepted
Headers show

Comments

Jun Wu - July 16, 2017, 6:23 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1500229020 25200
#      Sun Jul 16 11:17:00 2017 -0700
# Node ID 3fce51f52763323f1ff2e233e44aa926c2095d05
# Parent  d09de637cbc88ed2db989298115d0c0cb6cc6f27
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 3fce51f52763
commandserver: do not handle EINTR for selector.select

selectors2 library handles EINTR transparently so we don't need to handle
select.error ourselves.
Yuya Nishihara - July 17, 2017, 1:17 p.m.
On Sun, 16 Jul 2017 11:23:40 -0700, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark@fb.com>
> # Date 1500229020 25200
> #      Sun Jul 16 11:17:00 2017 -0700
> # Node ID 3fce51f52763323f1ff2e233e44aa926c2095d05
> # Parent  d09de637cbc88ed2db989298115d0c0cb6cc6f27
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r 3fce51f52763
> commandserver: do not handle EINTR for selector.select

Queued, thanks.

Patch

diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py
--- a/mercurial/commandserver.py
+++ b/mercurial/commandserver.py
@@ -12,5 +12,4 @@  import gc
 import os
 import random
-import select
 import signal
 import socket
@@ -489,13 +488,13 @@  class unixforkingservice(object):
                 self._unlinksocket()
                 exiting = True
+            ready = selector.select(timeout=h.pollinterval)
+            if not ready:
+                # only exit if we completed all queued requests
+                if exiting:
+                    break
+                continue
             try:
-                ready = selector.select(timeout=h.pollinterval)
-                if not ready:
-                    # only exit if we completed all queued requests
-                    if exiting:
-                        break
-                    continue
                 conn, _addr = self._sock.accept()
-            except (select.error, socket.error) as inst:
+            except socket.error as inst:
                 if inst.args[0] == errno.EINTR:
                     continue