strptime issue in multi-threaded application
jholloway7 at gmail.com
Tue Jun 16 12:52:43 EDT 2009
We recently uplifted our web application to run on Python 2.6.2.
We've noticed on a couple occasions that calls into time.strptime have
failed with this exception:
ImportError: Failed to import _strptime because the import lockis
[sic] held by another thread.
I poked around the source code enough to realize that this is
apparently due to time.strptime using PyImport_ImportModuleNoBlock
which potentially raises an ImportError rather than waiting for the
"import lock" to be released . This appears to have been
introduced as a workaround for other thread safety concerns .
Does this indicate that strptime and any other library function that
uses the non-blocking import call in this fashion are not thread safe?
Is there an idiomatic way of dealing with this error in
Like I mentioned, it's only happened on a couple occasions because the
right conditions have to be in place, but something doesn't seem right
about it. I thought I'd ask on the mailing list before going so far
as to open a ticket, but feel free to direct me there if that's the
appropriate place for this.
More information about the Python-list