https://gist.github.com/polyrabbit/5023268一个threading.local的实例相当于获得了当前线程的上下文环境,我先设置一个值再读取它为什么就读不到了呢??
如果改成这样就可以读到:
https://gist.github.com/polyrabbit/5023291难道在同一线程是两次调用threading.local返回的环境是不一样的?求解。。
P.S. 其实我就是想将一个状态量在两个模块间传递,但又不想用传参(参数太多了)和加锁(太麻烦)的方法,不知道用thread.local该怎么做
PP.S 怎么嵌入gist代码呀??