Patchwork D2844: commandserver: prefer first-party selectors module from Python 3 to backport

login
register
mail settings
Submitter phabricator
Date March 13, 2018, 10:14 p.m.
Message ID <differential-rev-PHID-DREV-yptm2zb2dimqaznvqaa4-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/29460/
State Superseded
Headers show

Comments

phabricator - March 13, 2018, 10:14 p.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Caught by some deprecation warnings on Python 3.7.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2844

AFFECTED FILES
  mercurial/commandserver.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py
--- a/mercurial/commandserver.py
+++ b/mercurial/commandserver.py
@@ -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