Skip to content

Replace using sys.exit with higher level error/logic handling, e.g. custom exception #4209

Open

Description

What is the idea?

We here at conda-forge use some of the conda build APIs for our work. The code has been getting an increasing number of sys.exit calls for errors, which are causing our jobs to die.

Instead, maybe the code should raise an error and then catch it at the highest level and call sys.exit? This preserves the internals for others while maintaining the same behavior.

Why is this needed?

sys.exit calls are harder to catch/debug when using conda_build as an API.

What should happen?

Review and ideally remove all sys.exit calls.

Additional Context

These sys.exit calls in conda-build are very painful for downstream users of the code base as a library (i.e., conda-forge). The reason is that in the python exception hierarchy has the SystemExit exception raised by sys.exit and the standard Exception at the same level (https://docs.python.org/3/library/exceptions.html#exception-hierarchy). This means when one calls sys.exit, the invoking code cannot catch that exception without resorting to explicitly catching SystemExit as opposed to a normal Exception. The slight change in exception handling API breaks (at least my) expectations as a user of the code and has created quite a few mystery code crashes in the bot over the years.

Can we use a standard exception here and then have the conda-build CLI code handle that exception and call sys.exit?

Originally posted by @beckermr in #5237 (comment)

Tasks

  1. cla-signed
    kenodegard
  2. cla-signed
    beeankha kenodegard
  3. cla-signed
    kenodegard
  4. cla-signed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Labels

duplicate::primaryif an issue/PR has duplicates, this is the consolidated, primary issue/PReffort-high[deprecated]in-progressissue is actively being worked onsource::communitycatch-all for issues filed by community membersstale::recovered[bot] recovered after being marked as staletype::tech-debtidentifies or resolves some technical debt

Type

No type

Projects

  • Status

    🏗️ In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions