9

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?

lemiant
  • 3,593
  • 3
  • 27
  • 36

1 Answers1

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.)

Daniel Roseman
  • 541,889
  • 55
  • 754
  • 786