Skip to content

ExceptionGroup support #43

@VincentVanlaer

Description

@VincentVanlaer

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:

task_group = await self.enter_async_context(anyio.create_task_group())

task_group = await self.enter_async_context(anyio.create_task_group())

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)

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)

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions