File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change 12
12
import shutil
13
13
import ssl
14
14
import subprocess
15
- from asyncio import as_completed , run
15
+ from asyncio import as_completed , create_task , run , wait
16
16
from pathlib import Path
17
17
from typing import TYPE_CHECKING , Any , Optional , TypedDict
18
18
@@ -322,11 +322,14 @@ async def _aiohttp_get_request(self, url):
322
322
return None
323
323
324
324
async def _async_get_request (self , uri , endpoints ):
325
- tasks = [self ._aiohttp_get_request (f"http://{ ip } :8008{ uri } " ) for ip in endpoints ] + [
326
- self ._aiohttp_get_request (f"https://{ ip } :8008{ uri } " ) for ip in endpoints
327
- ]
328
- for routine in as_completed (tasks ):
329
- if result := await routine :
325
+ tasks = [
326
+ create_task (self ._aiohttp_get_request (f"http://{ ip } :8008{ uri } " )) for ip in endpoints
327
+ ] + [create_task (self ._aiohttp_get_request (f"https://{ ip } :8008{ uri } " )) for ip in endpoints ]
328
+ for task in as_completed (tasks ):
329
+ if result := task .result ():
330
+ for task in tasks :
331
+ task .cancel ()
332
+ await wait (tasks )
330
333
return result
331
334
332
335
def parallel_patroni_get_request (self , uri : str , endpoints : list [str ] | None = None ) -> dict :
You can’t perform that action at this time.
0 commit comments