由于Python的datetime和time中的_strptime方法不支持多线程,运行时会报错:
import datetime
import thread
import time
def f():
for _ in xrange(3):
time.sleep(3)
Unhandled exception in thread started by <function f at 0x2b52c24e66e0>
Traceback (most recent call last):
AttributeErrorUnhandled exception in thread started by <function f at 0x2b52c24e66e0>:
Traceback (most recent call last):
_strptime
AttributeError: _strptime
在源文件中可以fix这个bug,不过对于用户来说,还是在使用的时候加锁吧。。
c = threading.RLock()
def f():