Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate with the exceptiongroup library #17

Closed
agronholm opened this issue Oct 16, 2018 · 7 comments
Closed

Integrate with the exceptiongroup library #17

agronholm opened this issue Oct 16, 2018 · 7 comments
Labels
enhancement New feature or request
Milestone

Comments

@agronholm
Copy link
Owner

The current implementation of exception groups in anyio is quite poor. This has been left alone because of the emerging exceptiongroup library which should provide a much better implementation. Once it's been released, we should add a dependency on it and remove our built-in implementation.

@agronholm agronholm added the enhancement New feature or request label Oct 16, 2018
@agronholm agronholm added this to the 1.0.0 milestone Oct 16, 2018
@agronholm agronholm removed this from the 1.0.0 milestone Nov 10, 2018
@agronholm
Copy link
Owner Author

I removed this from the 1.0.0 target because the exceptiongroup library is nowhere near release ready. It needs plenty of work to get there.

@agronholm agronholm added this to the 1.1.0 milestone Nov 14, 2018
@smurfix
Copy link
Collaborator

smurfix commented Jul 30, 2019

This effort should be restarted, because as it is anyio is no longer compatible with Trio master.

______________________________________ test_multi_error_host[trio] ______________________________________
anyio/_backends/_trio.py:121: in __aexit__
    return await self._nursery_manager.__aexit__(exc_type, exc_val, exc_tb)
../trio/trio/_core/_run.py:725: in __aexit__
    raise combined_error_from_nursery
E   trio.MultiError: Exception('host'), Exception('child')

During handling of the above exception, another exception occurred:
tests/test_taskgroups.py:205: in test_multi_error_host
    raise Exception('host')
anyio/_backends/_trio.py:123: in __aexit__
    raise TrioExceptionGroup(exc.exceptions) from None
../trio/trio/_core/_multierror.py:184: in __init__
    assert len(exceptions) == 1 and exceptions[0] is self
E   AssertionError

@agronholm
Copy link
Owner Author

The library isn't ready yet, and I've committed a much simpler fix in master now.

@agronholm agronholm removed this from the 1.1.0 milestone Aug 7, 2019
@agronholm agronholm added this to the 2.0.0 milestone Oct 3, 2019
@agronholm agronholm modified the milestones: 2.0.0, 3.0.0 Jan 1, 2020
@agronholm agronholm removed this from the 3.0.0 milestone Feb 11, 2021
@agronholm
Copy link
Owner Author

What I could do at this point is to modify AnyIO's ExceptionGroup API to match PEP 654.

@agronholm
Copy link
Owner Author

I just tried, and the problem is that trio's MultiError is not compatible with this spec (it just takes a bunch of exceptions but not an error message). Any code that needs to raise an exception group must actually raise a MultiError in trio or else it will not be handled correctly.

@agronholm
Copy link
Owner Author

agronholm commented Feb 23, 2021

Actually, I already had in place a workaround where a trio-specific ExceptionGroup inherits from MultiError. I still need to improve my understanding of how __new__() and __init__() work before I can get this working.

@agronholm
Copy link
Owner Author

Got it now – all tests pass. I'll polish this later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants