import datetime,threading
lockObject = threading.Lock()
def testTime():
global lockObject
'''这个地方加个线程锁,_strptime_time 线程不安全'''
lockObject.acquire()
t = datetime.datetime.now()
timeStamp = time.mktime(t.timetuple())
lockObject.release()
return timeStamp
def getTodayTimeStamp():
global lockObject
'''这个地方加个线程锁,_strptime_time 线程不安全'''
lockObject.acquire()
now = datetime.datetime.now()
timeStamp = '%s 00:00:00' % now.strftime( '%Y-%m-%d' )
timeStamp = time.strptime( timeStamp, '%Y-%m-%d %X' )
timeStamp = int(time.mktime( timeStamp ))
lockObject.release()
return timeStamp