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

Fix wsgi_app - flag parsing & singleton #214

Merged
merged 1 commit into from
May 10, 2024
Merged

Conversation

wwwillchen
Copy link
Collaborator

@wwwillchen wwwillchen commented May 9, 2024

This fixes two related issues fixed with our wsgi_app implementation:

  • Previously, there was no flag parsing (for absl-py) when running Mesop via gunicorn (recommended for production serving) which resulted in a UnparsedFlagAccessError, because of this flag: https://github.com/google/mesop/blob/8ccc8d234f33d675fe3018c10817be917ee3a1a7/mesop/runtime/context.py#L15C1-L16C1. This uses the manual flag parsing method, instead of the usual app.run because app.run never returns, so we can't use it here.
  • Previously, we were creating a new Flask app instance for each request, which technically works, but it's wasteful since a Flask app is supposed to be persistent. This saves ~5ish ms per request by caching the Flask app instance. This is also nice because then we can just parse the flags once too.

@wwwillchen wwwillchen force-pushed the fix_wsgi branch 2 times, most recently from aab896b to 0ed8a45 Compare May 9, 2024 23:53
@wwwillchen wwwillchen changed the title Fix wsgi Fix wsgi_app - flag parsing & singleton May 9, 2024
@wwwillchen wwwillchen merged commit df24d1c into google:main May 10, 2024
2 checks passed
richard-to pushed a commit to richard-to/mesop that referenced this pull request May 13, 2024
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.

1 participant