Skip to content

deprecate before_first_request #4605

@davidism

Description

@davidism

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions