Skip to content

Exception semantics of run_process with strict_exception_groups #2923

@jakkdl

Description

@jakkdl

Currently, with a default of strict_exception_groups=false, run_process will currently almost always return singular exceptions, only giving multiple exceptions (afaik) if it encounters problems with reading from input/output streams.

with #2886 that will change, where any exception encountered when running the user-specified deliver_cancel, plus stream errors, will be wrapped. @Zac-HD initially favored reraising groups as TrioInternalError with the group as a cause - but after discussion with @richardsheridan I'm punting it to a separate issue & PR.

Possible solutions include:

  • Be open about the fact that there's a nested nursery, and you will get an ExceptionGroup if there's a problem in it. [Status Quo in change strict_exception_groups default to True #2886]
  • specify strict_exception_groups=false to the nested nursery a la Fix regressions introduced when hiding Nursery.start implementation-detail nursery #2845 - but that still leaves the theoretical possibility of getting exceptiongroups in weird cases (unless those are then caught and reraised as a different exceptions), and if we're to deprecate loose exception groups then it seems bad to use it here.
  • catch ExceptionGroups from the nursery, and reraise as TrioInternalError, unless they're all Cancelled so as not to mess with Cancellations.
  • Do special handling of exceptions in deliver_cancel, marking them and extracting them from the exceptiongroup to be raised.
  • If there's only a single exception in the group, extract and raise it.
  • Wrap all other exceptions in exceptiongroups.
  • ... likely much better solutions I'm not aware of

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions