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
--- 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