You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "/usr/lib/python3.7/contextlib.py", line 635, in __aexit__
cb_suppress = await cb(*exc_details)
File "/usr/lib/python3.7/contextlib.py", line 539, in _exit_wrapper
return await cm_exit(cm, exc_type, exc, tb)
File "/.../python3.7/site-packages/anyio/_backends/_trio.py", line 123, in __aexit__
raise TrioExceptionGroup(exc.exceptions) from None
File "/.../python3.7/site-packages/trio/_core/_multierror.py", line 184, in __init__
assert len(exceptions) == 1 and exceptions[0] is self
AssertionError
So it's related to anyio exception groups. The base class ExceptionGroup has an exceptions attribute, and TrioExceptionGroup inherits from ExceptionGroup and trio.MultiError.
Hmm, I see in anyio head some hack for Trio 0.12 to turn around and delete the attribute.
I definitely haven't thought through how to support subclassing on MultiError... @agronholm, I guess you're the one doing the subclassing here; any thoughts? I think the proximal change that's triggering this is probably #1067 / #1066
That change in trio was not particularly welcomed by yours truly, as it completely broke anyio compatibility and I had to do the hack mentioned by @belm0 to work around it. I've never seen guards like that anywhere else. How exactly did you trigger the problem @belm0 ?
It's a non-trivial app, I can't offer a repro at this point.
I'm sure that the behavior is different between anyio 1.0.0 and head, yet the latter is not sufficient.
From the debugging I did above, I think we can conclude that with subclassing and/or multiple inheritance there are other paths where __init__() may be called on an existing object, beyond what is assumed in the Trio code.
Activity
belm0 commentedon Aug 27, 2019
When
__init__()is invoked, theexceptionsclass instance member is an empty tuple.And here is the value of the
exceptionsarg, in all its glory (ConnectionClosedis from trio_websocket):belm0 commentedon Aug 27, 2019
So it's related to anyio exception groups. The base class
ExceptionGrouphas anexceptionsattribute, andTrioExceptionGroupinherits fromExceptionGroupandtrio.MultiError.Hmm, I see in anyio head some hack for Trio 0.12 to turn around and delete the attribute.
https://github.com/agronholm/anyio/blob/37c1e21c4edd2a5c35706144f6813139ec57af5f/anyio/exceptions.py#L10-L11
quite a mess all around...
belm0 commentedon Aug 27, 2019
I tried anyio HEAD.
Same problem, although now theexceptionsclass instance member is populated rather than an empty tuple:So it's to do with multiple inheritance and MultiError?
njsmith commentedon Aug 27, 2019
I definitely haven't thought through how to support subclassing on
MultiError... @agronholm, I guess you're the one doing the subclassing here; any thoughts? I think the proximal change that's triggering this is probably #1067 / #1066agronholm commentedon Aug 27, 2019
That change in trio was not particularly welcomed by yours truly, as it completely broke anyio compatibility and I had to do the hack mentioned by @belm0 to work around it. I've never seen guards like that anywhere else. How exactly did you trigger the problem @belm0 ?
belm0 commentedon Aug 27, 2019
Are we sure that MultiError worked correctly in the face of subclassing / multiple inheritance even prior to that change?
agronholm commentedon Aug 27, 2019
Well, at least it was fine in anyio as far as I can tell.
agronholm commentedon Aug 27, 2019
@belm0 tell me again, how are you triggering the problem on the latest master version of anyio? The test suite passes just fine.
belm0 commentedon Aug 27, 2019
It's a non-trivial app, I can't offer a repro at this point.
I'm sure that the behavior is different between anyio 1.0.0 and head, yet the latter is not sufficient.
From the debugging I did above, I think we can conclude that with subclassing and/or multiple inheritance there are other paths where
__init__()may be called on an existing object, beyond what is assumed in the Trio code.agronholm commentedon Aug 27, 2019
Are you by any chance serializing the MultiErrors, possibly via multiprocessing?
agronholm commentedon Aug 27, 2019
I guess not. But can you at least find out what exactly is being passed to TrioExceptionGroup's constructor?
belm0 commentedon Aug 27, 2019
Sorry, operator error here. Indeed, there is not an AssertionError from Trio with anyio HEAD.
So outstanding is to decide on policy about MultiError inheritance, and whether to make the internals less fragile.
Zac-HD commentedon Nov 3, 2022
Closing this because we've dropped MultiError.