Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an --app= flag for specifying the WSGI application #457

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

kgaughan
Copy link
Member

@kgaughan kgaughan commented Nov 24, 2024

This is essentially a less-invasive version of #441. As with that PR, this PR adds support for a --app flag for specifying the WSGI app to run. Unlike that one, it maintains the getopt-based implementation. There's certainly some value in moving to argparse at some point, but it'd need to integrate properly with the Adjustments class.

Closes #439, closes #441.

Some incidental changes that grew out of this:

  • The capture() context manager is now more well-behaved as it respects the previous values of sys.stderr and sys.stdin, and restores them in a finally block if there's an exception.
  • Adjustments.parse_cli() is now responsible for resolving the app descriptor. This forces some of the tests to be a bit more realistic.
  • A stacktrace is now printed if there's an issue resolving an app descriptor, which should be useful if, say, and ImportError was caused secondarily by a different exception in the app itself. This should keep the spirit of show_exception, while leaning on the standard library more.

The dunder attributes shouldn't really be touched directly, and if
something else is already capturing these streams, this method is less
likely to mess things up.
I somehow had it in my head that this was some leftover debug code I'd
written, but it's not. it was introduced back in Pylons#102. With that in
mind, I've restored it _functionally_, but it now leans on the
`traceback` to print a stacktrace instead.
@kgaughan
Copy link
Member Author

@mmerickel If you get a chance, I appreciate a review from another maintainer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make MODULE:APP non-positional (but still required) argument
2 participants