Closed tvuotila closed 4 years ago
@tvuotila: Isn't this the same as #125? Can you check if these changes are identical, or if there are any differences?
@tvuotila: Isn't this the same as #125? Can you check if these changes are identical, or if there are any differences?
They solve the same problem, but I notice an issue there.
I close this because #125 is better
Allow multiple request to share the same application.
Problem: We are running Flask with Gunicorn with gevent worker type. This means, that when a request processing is waiting for an i/o, another request processing can start.
In my tests, I managed to have two requests use the same application object through
current_app
proxy. This introduced the following bug:force_locale
block, which replacesbabel.locale_selector_func
with lambda A. Originallocale_selector_func
is saved.force_locale
block, which replacesbabel.locale_selector_func
with lambda B. Lambda A is saved.force_locale
block.babel.locale_selector_func
is replaced with the the originallocale_selector_func
.force_locale
block.babel.locale_selector_func
is replaced by lambda A.Now
babel.locale_selector_func
is lambda A instead of the originallocale_selector_func
.My solution to the problem: Store forced
locale_selector_func
per request. Try to getlocale_selector_func
first from the request info and fall back to the one stored in the application object.