import asyncio async def nested(): return 42 async def main(): # Schedule nested() to run soon concurrently # with "main()". task = asyncio.create_task(nested()) # "task" can now be used to cancel "nested()", or
asyncio.waitaccepts a Iterable[Awaitable[_T]] as its first parameter. However it will hang forever if we passes an invalid Awaitable to it and there are subprocesses wrapped in asyncio.Task running. To sum up, we have to meet these condi...
sleep(sleep_time) print(f"Data with id: {id} fetched successfully") return {"id": id, "data": id} async def main(): tasks = [] async with asyncio.TaskGroup() as tg: for i in range(1, 4): task = tg.create_task(fetch_data(i, i)) tasks.append(task) results = await ...
24.5.2: add asyncio/anyio taskgroup support to ASYNC101 (#244) jakkdl tagged this 13 May 17:14 * add asyncio/anyio taskgroup support to ASYNC101. Fix func_has_decorator to recognize decorators that are calls but not attributes. Clarify difference between ASYNC101 and ASYNC119 * changelog ...
sleep(sleep_time) print(f"Data with id: {id} fetched successfully") return {"id": id, "data": id} async def main(): tasks = [] async with asyncio.TaskGroup() as tg: for i in range(1, 4): task = tg.create_task(fetch_data(i, i)) tasks.append(task) results = await ...