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
标题: mimetypes.MAGIC_FUNCTION initialization not thread-safe in Python 2.6.2
类型: behavior Stage:
Components: Library (Lib) Versions: Python 2.6
process
状态: closed Resolution: duplicate
Dependencies: 后续: mimetypes.guess_type() hits recursion limit
View: 5853
分配给: 抄送列表: apoirier, benjamin.peterson, pitrou
优先级: normal 关键字:

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) 日期: 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) 日期: 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.
历史
日期 用户 动作 参数
2022-04-11 14:56:48admin修改github: 50118
2009-04-28 14:58:06pitrou修改状态: open -> closed

抄送: + pitrou
消息: + msg86748

后续: mimetypes.guess_type() hits recursion limit
resolution: duplicate
2009-04-28 14:51:56apoirier创建