-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Always close _all_ ijson
coroutines, even if doing so raises Exceptions
#14065
Conversation
ijson
coroutines, even if doing so raises Exceptions
Thanks for picking this up! |
raise ExceptionBundle( | ||
f"There were {len(exceptions)} errors closing coroutines", exceptions | ||
) from exceptions[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not promising this is the cleanest way to do it---there are no tracebacks for exceptions[1:]
---but this seemed Good Enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I'm not sure what @richvdh meant by exception chanining in #13293 (comment) ---something along these lines?)
parts.append(str(e)) | ||
super().__init__("\n - ".join(parts)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm specifically trying to ensure each exception's summary is included here, even if we don't have their tracebacks.
There are some comments in the description elaborating on why I didn't want to use the backport here,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good to me, thanks!
Fixes #13293. Improves on #12875 and #9958.
This change means that we should raise one Sentry event for each such failure to
.finish()
a parser, instead of an event for each line printed to stderr.I have only included the first traceback
exceptions[0]
: I'm assuming that's enough to diagnose what happened if we see this error. I do make sure to include thestr()
of each individual exception though.I considered using https://pypi.org/project/exceptiongroup/ but this was a little scary: it mentions patching TracebackException and adding exception hooks; I feared that this wouldn't play nicely with twisted + logcontexts + other arcanery in Synapse I don't grok.