PK œqhYî¶J‚ßF ßF ) nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/
| Dir : /opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/utils/ |
| Server: Linux cloud.virginhosting.lk 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64 IP: 128.140.68.198 |
| Dir : //opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/utils/async_utils.py |
from typing import List, Union, Tuple
import asyncio
class AsyncIterate: # not AsyncIterable because python use this name already
def __init__(self, data: Union[List, Tuple]):
self.queue = iter(data)
def __aiter__(self):
return self
async def __anext__(self):
data = await self.fetch_data()
if data is not None:
return data
else:
raise StopAsyncIteration
async def fetch_data(self):
try:
item = next(self.queue)
except StopIteration:
item = None
return item
async def gather(*tasks: List) -> AsyncIterate:
results = await asyncio.gather(*tasks)
return AsyncIterate(results)