diff options
| author | Alexandre Flament <alex@al-f.net> | 2021-04-27 20:06:54 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-27 20:06:54 +0200 |
| commit | b06a15376c546bb216ed7fa5e8f2f8b793420f33 (patch) | |
| tree | b57413a1b766d08e6f40aebe2a166c564fa26213 /searx/network/network.py | |
| parent | f724d6f6f1a38d11bc26c39648441bc8788b4288 (diff) | |
| parent | 283ae7bfad05fedbf6c7a7e7d7addfc3ae7ed9c7 (diff) | |
Merge pull request #32 from searxng/fix-network
[fix] searx.network: fix rare cases where LOOP is None
Diffstat (limited to 'searx/network/network.py')
| -rw-r--r-- | searx/network/network.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/searx/network/network.py b/searx/network/network.py index 15c23d193..bb822a7d3 100644 --- a/searx/network/network.py +++ b/searx/network/network.py @@ -7,7 +7,7 @@ from itertools import cycle import httpx -from .client import new_client, LOOP +from .client import new_client, get_loop DEFAULT_NAME = '__DEFAULT__' @@ -291,8 +291,9 @@ def done(): So Network.aclose is called here using atexit.register """ try: - if LOOP: - future = asyncio.run_coroutine_threadsafe(Network.aclose_all(), LOOP) + loop = get_loop() + if loop: + future = asyncio.run_coroutine_threadsafe(Network.aclose_all(), loop) # wait 3 seconds to close the HTTP clients future.result(3) finally: |