-
Notifications
You must be signed in to change notification settings - Fork 15
Description
Since anyio 4.0, all task groups raise ExceptionGroups by default. We need to check whether that causes us to miss exceptions, and whether we are passing exception groups to users where we do not intent to raise one.
I did a quick scan for where we use task groups in the main code, assuming that no other anyio functions raise exception groups:
purerpc/src/purerpc/grpc_socket.py
Line 30 in a3c17dd
task_group = await self.enter_async_context(anyio.create_task_group()) |
purerpc/src/purerpc/grpc_socket.py
Line 216 in a3c17dd
task_group = await self.enter_async_context(anyio.create_task_group()) |
purerpc/src/purerpc/wrappers.py
Lines 103 to 107 in a3c17dd
async def __call__(self, message_aiter, *, metadata=None): | |
stream = await self._stream_fn(metadata=metadata) | |
async with anyio.create_task_group() as task_group: | |
task_group.start_soon(send_multiple_messages_client, stream, message_aiter) | |
return await extract_message_from_singleton_stream(stream) |
purerpc/src/purerpc/wrappers.py
Lines 112 to 117 in a3c17dd
async def call_aiter(self, message_aiter, metadata): | |
stream = await self._stream_fn(metadata=metadata) | |
async with anyio.create_task_group() as task_group: | |
task_group.start_soon(send_multiple_messages_client, stream, message_aiter) | |
yield stream_to_async_iterator(stream) |
Lines 219 to 225 in a3c17dd
async with GRPCProtoSocket(self.config, stream_) as grpc_socket: | |
# TODO: resource usage warning | |
# TODO: TaskGroup() uses a lot of memory if the connection is kept for a long time | |
# TODO: do we really need it here? | |
async with anyio.create_task_group() as task_group: | |
async for stream in grpc_socket.listen(): | |
task_group.start_soon(self.request_received, stream) |
Other uses of tasks groups is in tests and some sample scripts. While those probably should be double checked, the ones above are the most important ones.