commandserver: prefer first-party selectors module from Python 3 to backport
authorAugie Fackler <augie@google.com>
Tue, 13 Mar 2018 18:04:37 -0400
changeset 36946 b0ffcb540357
parent 36945 45bfcd16f27e
child 36947 3f7bbce8fbaa
commandserver: prefer first-party selectors module from Python 3 to backport Caught by some deprecation warnings on Python 3.7. Differential Revision: https://phab.mercurial-scm.org/D2844
mercurial/commandserver.py
--- a/mercurial/commandserver.py	Sat Mar 10 12:33:19 2018 +0530
+++ b/mercurial/commandserver.py	Tue Mar 13 18:04:37 2018 -0400
@@ -16,8 +16,13 @@
 import struct
 import traceback
 
+try:
+    import selectors
+    selectors.BaseSelector
+except ImportError:
+    from .thirdparty import selectors2 as selectors
+
 from .i18n import _
-from .thirdparty import selectors2
 from . import (
     encoding,
     error,
@@ -476,8 +481,8 @@
     def _mainloop(self):
         exiting = False
         h = self._servicehandler
-        selector = selectors2.DefaultSelector()
-        selector.register(self._sock, selectors2.EVENT_READ)
+        selector = selectors.DefaultSelector()
+        selector.register(self._sock, selectors.EVENT_READ)
         while True:
             if not exiting and h.shouldexit():
                 # clients can no longer connect() to the domain socket, so