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
Actually, using Result.acapture in that example is wrong, because it'll swallow KeyboardInterrupt and Cancelled exceptions. We want something more like a conventional catch-all handler, like except Exception. And conventionally that would mean it needs to be replaced by MultiError.catch. Here we only really want to catch the Exception part of the MultiError, but in the common case where that's the whole MultiError, we want to preserve it as a single MultiError that we can pack into an Error object and add to the results list. Hmm.
I wonder if we should add something like a MultiError.split primitive that divides a MultiError into two pieces, those that match the predicate and those that don't... And maybe a catch_split built on it that catches all exceptions of a given class and hands them all at once to a handler? These might actually be the primitives we want for both cancel scopes and the log-and-discard-errors cases.
For example, maybe something like:
https://gist.github.com/njsmith/986b0d0e04c3b2bb45de5d662ae873d5
Or the same but with
results[i] = await trio.hazmat.Result.acapture(async_fn)
.The text was updated successfully, but these errors were encountered: