]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
threading is always available from 3.7 on
authorBob Halley <halley@dnspython.org>
Fri, 18 Mar 2022 12:09:34 +0000 (05:09 -0700)
committerBob Halley <halley@dnspython.org>
Fri, 18 Mar 2022 12:09:34 +0000 (05:09 -0700)
dns/entropy.py
dns/resolver.py
dns/versioned.py
dns/win32util.py

index 5010356280e2bb6545b1bf093e470e02e11bd671..5e1f5e236e488373091357c68cd68115dcc652a9 100644 (file)
@@ -20,13 +20,9 @@ from typing import Any, Optional
 import os
 import hashlib
 import random
+import threading
 import time
 
-try:
-    import threading as _threading
-except ImportError:  # pragma: no cover
-    import dummy_threading as _threading  # type: ignore
-
 
 class EntropyPool:
 
@@ -39,7 +35,7 @@ class EntropyPool:
         self.pool_index = 0
         self.digest: Optional[bytearray] = None
         self.next_byte = 0
-        self.lock = _threading.Lock()
+        self.lock = threading.Lock()
         self.hash = hashlib.sha1()
         self.hash_len = 20
         self.pool = bytearray(b"\0" * self.hash_len)
index 3b76100c90a3abd91e94104dc87002c8376532ca..ac34be8779d18184aadefdead37266c2d25fe359 100644 (file)
@@ -23,15 +23,11 @@ from urllib.parse import urlparse
 import contextlib
 import socket
 import sys
+import threading
 import time
 import random
 import warnings
 
-try:
-    import threading as _threading
-except ImportError:  # pragma: no cover
-    import dummy_threading as _threading  # type: ignore
-
 import dns.exception
 import dns.edns
 import dns.flags
@@ -330,7 +326,7 @@ class CacheStatistics:
 
 class CacheBase:
     def __init__(self):
-        self.lock = _threading.Lock()
+        self.lock = threading.Lock()
         self.statistics = CacheStatistics()
 
     def reset_statistics(self) -> None:
index 5cf29e99859a4a3db42ab84ad8aeb41e1dea238c..02e24122a86a647d69edf4bbcc8460ec11a82b05 100644 (file)
@@ -5,11 +5,7 @@
 from typing import Callable, Deque, Optional, Set, Union
 
 import collections
-
-try:
-    import threading as _threading
-except ImportError:  # pragma: no cover
-    import dummy_threading as _threading  # type: ignore
+import threading
 
 import dns.exception
 import dns.immutable
@@ -73,14 +69,14 @@ class Zone(dns.zone.Zone):  # lgtm[py/missing-equals]
         """
         super().__init__(origin, rdclass, relativize)
         self._versions: Deque[Version] = collections.deque()
-        self._version_lock = _threading.Lock()
+        self._version_lock = threading.Lock()
         if pruning_policy is None:
             self._pruning_policy = self._default_pruning_policy
         else:
             self._pruning_policy = pruning_policy
         self._write_txn: Optional[Transaction] = None
-        self._write_event: Optional[_threading.Event] = None
-        self._write_waiters: Deque[_threading.Event] = collections.deque()
+        self._write_event: Optional[threading.Event] = None
+        self._write_waiters: Deque[threading.Event] = collections.deque()
         self._readers: Set[Transaction] = set()
         self._commit_version_unlocked(
             None, WritableVersion(self, replacement=True), origin
@@ -145,7 +141,7 @@ class Zone(dns.zone.Zone):  # lgtm[py/missing-equals]
                 # Someone else is writing already, so we will have to
                 # wait, but we want to do the actual wait outside the
                 # lock.
-                event = _threading.Event()
+                event = threading.Event()
                 self._write_waiters.append(event)
             # wait (note we gave up the lock!)
             #
index 7a17b0bbf8dadceb537741565cf06b33bd77d5a9..14fc17e0db2b2e1eb9a18bc0244c2ca841f7da5b 100644 (file)
@@ -11,10 +11,7 @@ if sys.platform == "win32":
     import winreg
 
     try:
-        try:
-            import threading as _threading
-        except ImportError:  # pragma: no cover
-            import dummy_threading as _threading  # type: ignore
+        import threading
         import pythoncom
         import wmi
 
@@ -38,7 +35,7 @@ if sys.platform == "win32":
 
     if _have_wmi:
 
-        class _WMIGetter(_threading.Thread):
+        class _WMIGetter(threading.Thread):
             def __init__(self):
                 super().__init__()
                 self.info = DnsInfo()