When flask g keep data on one request and another request follow almost simultaneously (race condition). Will flask g be replaced by new flask g?. And how i can handle if this situation happen. Thank you.
Asked
Active
Viewed 188 times
0
-
That should be easy to test. – Klaus D. Dec 29 '19 at 16:20
-
One simple way to test this is to add a call to [sleep](https://stackoverflow.com/a/64486) in your code and write a test that makes two requests in quick-enough succession. A somewhat better way is to make the request handler tell the test that it's started and then wait to proceed, perhaps using mocking. Goog luck. – arnt Dec 29 '19 at 17:08
1 Answers
0
This is no problem. In flask every simultaneous request will be handled in a separate process. There will be multiple g
at a given time (depending on how you configure gunicorn) but every process will have it's own instance.

mousetail
- 7,009
- 4
- 25
- 45