In flask every function has access to a request global. How do the designers of flask stop that global from being overwritten in the middle of one request when another one starts?
Asked
Active
Viewed 2,928 times
1 Answers
9
It's a threadlocal, not a true global. Since each thread can only be dealing with one request at a time, there's no danger of interference.
In fact there's a full description of exactly this in the Flask docs here.
(Still doesn't necessarily make it a good design, of course.)
![](../../users/profiles/104349.webp)
Daniel Roseman
- 541,889
- 55
- 754
- 786
-
That's very cool. Thanks for the link too. Is it possible/adviseable to bind your own information in that way? – lemiant May 18 '14 at 21:17
-
5For a 'bad design' it works really very well, though. I admire the architecture, FWIW. – Martijn Pieters May 18 '14 at 21:53