flask之Context

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
In [1]: import threa
thread threading
In [1]: import threading
In [2]: storage = threading.local()
In [3]: stor
%store storage
In [3]: storage.foo = 1
In [4]: print sto
%store storage
In [4]: print stor
%store storage
In [4]: print storage.foo
1
In [5]: class AnotherThread(threading.T
threading.Thread threading.ThreadError threading.Timer
In [5]: class AnotherThread(threading.Th
threading.Thread threading.ThreadError
In [5]: class AnotherThread(threading.Thread):
...: def run(self):
...: storage.foo = 2
...: print storage.foo
...:
In [6]: another = AnotherThread()
In [7]: another.start()
2
In [8]: print storage.foo
1