if readable and isinstance(fd, ssl.SSLSocket) and fd.pending() > 0:
return True
- sel = _selector_class()
+ sel = selectors.DefaultSelector()
events = 0
if readable:
events |= selectors.EVENT_READ
raise dns.exception.Timeout
-def _set_selector_class(selector_class):
- # Internal API. Do not use.
-
- global _selector_class
-
- _selector_class = selector_class
-
-
-if hasattr(selectors, "PollSelector"):
- # Prefer poll() on platforms that support it because it has no
- # limits on the maximum value of a file descriptor (plus it will
- # be more efficient for high values).
- #
- # We ignore typing here as we can't say _selector_class is Any
- # on python < 3.8 due to a bug.
- _selector_class = selectors.PollSelector # type: ignore
-else:
- _selector_class = selectors.SelectSelector # type: ignore
-
-
def _wait_for_readable(s, expiration):
_wait_for(s, True, False, True, expiration)
UnexpectedEOF,
)
-# Avoid circularity with dns.query
-if hasattr(selectors, "PollSelector"):
- _selector_class = selectors.PollSelector # type: ignore
-else:
- _selector_class = selectors.SelectSelector # type: ignore
-
class SyncQuicStream(BaseQuicStream):
def __init__(self, connection, stream_id):
def _worker(self):
try:
- sel = _selector_class()
+ sel = selectors.DefaultSelector()
sel.register(self._socket, selectors.EVENT_READ, self._read)
sel.register(self._receive_wakeup, selectors.EVENT_READ, self._drain_wakeup)
while not self._done:
res.nameservers = [ns]
-class PollingMonkeyPatchMixin(object):
- def setUp(self):
- self.__native_selector_class = dns.query._selector_class
- dns.query._set_selector_class(self.selector_class())
-
- unittest.TestCase.setUp(self)
-
- def tearDown(self):
- dns.query._set_selector_class(self.__native_selector_class)
-
- unittest.TestCase.tearDown(self)
-
-
-class SelectResolverTestCase(
- PollingMonkeyPatchMixin, LiveResolverTests, unittest.TestCase
-):
- def selector_class(self):
- return selectors.SelectSelector
-
-
-if hasattr(selectors, "PollSelector"):
-
- class PollResolverTestCase(
- PollingMonkeyPatchMixin, LiveResolverTests, unittest.TestCase
- ):
- def selector_class(self):
- return selectors.PollSelector
-
-
class NXDOMAINExceptionTestCase(unittest.TestCase):
# pylint: disable=broad-except