-
-
Notifications
You must be signed in to change notification settings - Fork 16.7k
Closed
Milestone
Description
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
ifcheck, 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.Lockis not useful for an eventual ASGI implementation.
tabebqena