Since the _ strptime method in datetime and time in Python does not support multithreading, an error is reported during running:
Import datetime
Import thread
Import time
Def F ():
Datetime. datetime. strptime ("20100101", "% Y % m % d ")
For _ in xrange (3 ):
Thread. start_new_thread (F ,())
Time. Sleep (3)
Unhandled exception in thread started by <function f at 0x2b52c24e66e0>
Traceback (most recent call last ):
File "test. py", line 7, in F
Datetime. datetime. strptime ("20100101", "% Y % m % d ")
Attributeerrorunhandled exception in thread started by <function f at 0x2b52c24e66e0>:
Traceback (most recent call last ):
File "test. py", line 7, in F
_ Strptime
Datetime. datetime. strptime ("20100101", "% Y % m % d ")
Attributeerror: _ strptime
Reference http://bugs.python.org/issue7980
You can fix this bug in the source file, but for the user, lock it when using it ..
C = threading. rlock ()
Def F ():
With C:
Datetime. datetime. strptime ("20100101", "% Y % m % d ")
Rlock reference
Http://www.ourunix.org/post/335.html