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

deprecate before_first_request #4605

Closed
davidism opened this issue May 23, 2022 · 0 comments · Fixed by #4621
Closed

deprecate before_first_request #4605

davidism opened this issue May 23, 2022 · 0 comments · Fixed by #4621
Assignees
Milestone

Comments

@davidism
Copy link
Member

While reviewing the consistent use of setupmethod for #4571 and #4577, I'm realizing that before_first_request should probably be deprecated then removed.

  • There's no example use cases in the docs.
  • From examples I've seen on Stack Overflow and around the web, it seems to be (mis)used as a setup method, to do something "before the application starts".
  • Configuration should be done before running the application, during the actual setup phase. Preferably, it should be done in a factory function.
  • It incurs a function call before every request, for something that only happens once. This can be inlined to only incur an if check, but it's not ideal.
  • It runs before the first request for every instance, which is every or almost every time for many process worker implementations, and only once for the dev server (the only thread worker I'm aware of). The threading.Lock is not useful for an eventual ASGI implementation.
@davidism davidism self-assigned this May 23, 2022
@davidism davidism added this to the 2.2.0 milestone Jun 6, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant