diff options
| author | Alexandre Flament <alex@al-f.net> | 2021-02-12 10:56:40 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-12 10:56:40 +0100 |
| commit | 7e83818879a48fef84a518092d833e3785c64ff2 (patch) | |
| tree | 2720ac7268671fe0d40243468e3071422077375b /searx/poolrequests.py | |
| parent | 63d6ccfbc2f1a61a2b0b9040d89858a540ede475 (diff) | |
| parent | d2dac11392c89084e8d6143f09c27c5fefabdef9 (diff) | |
Merge pull request #2560 from dalf/fix-duckduckgo
Fix duckduckgo
Diffstat (limited to 'searx/poolrequests.py')
| -rw-r--r-- | searx/poolrequests.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/searx/poolrequests.py b/searx/poolrequests.py index 25a6baed9..8b8681437 100644 --- a/searx/poolrequests.py +++ b/searx/poolrequests.py @@ -1,7 +1,7 @@ import sys from time import time from itertools import cycle -from threading import RLock, local +from threading import local import requests @@ -88,10 +88,12 @@ class SessionSinglePool(requests.Session): super().__init__() # reuse the same adapters - with RLock(): - self.adapters.clear() - self.mount('https://', next(https_adapters)) - self.mount('http://', next(http_adapters)) + self.adapters.clear() + + https_adapter = threadLocal.__dict__.setdefault('https_adapter', next(https_adapters)) + http_adapter = threadLocal.__dict__.setdefault('http_adapter', next(http_adapters)) + self.mount('https://', https_adapter) + self.mount('http://', http_adapter) def close(self): """Call super, but clear adapters since there are managed globaly""" |