This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: mimetypes.MAGIC_FUNCTION initialization not thread-safe in Python 2.6.2
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: mimetypes.guess_type() hits recursion limit
View: 5853
Assigned To: Nosy List: apoirier, benjamin.peterson, pitrou
Priority: normal Keywords:

Created on 2009-04-28 14:51 by apoirier, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg86747 - (view) Author: Alain Poirier (apoirier) Date: 2009-04-28 14:51
In Python 2.6.2, the fix for the issue 5401 changed the way the
mimetypes module is initialized.

But now the initialization is not thread-safe : a thread can set
``inited`` to ``True`` and then be preempted before to overwrite the
functions guess_type(), guess_extension() ...

With such a partial initialization, the next thread will raise an 
excessive recursion exception when calling one of this functions.

A fix could be to wrap ``mimetypes.init()`` with a thread lock.
msg86748 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-04-28 14:58
Already fixed in r72048.
If you try the fix and find out it has some problems, please reopen the bug.
History
Date User Action Args
2022-04-11 14:56:48adminsetgithub: 50118
2009-04-28 14:58:06pitrousetstatus: open -> closed

nosy: + pitrou
messages: + msg86748

superseder: mimetypes.guess_type() hits recursion limit
resolution: duplicate
2009-04-28 14:51:56apoiriercreate