bug in UnknownFileTypeServlet.py (guess_type multithread)
Sophana KOK <[email protected]> Fri, 24 Sep 2010 20:53:34 +0200
| Newsgroups | gmane.comp.python.webware |
|---|---|
| Message-ID | <[email protected]> |
Hi
I tested webware 1.0.2 on python 2.6.2 (fedora 12) and came into a bug
that I could find.
from python 2.6 guess_type implementation doesn't support multi threading.
The symptom is an infinite recursion exception on guess_type when it
is called concurrently
Looking in webware trunk I could see it that the exception is catched:
try:
mimeType, mimeEncoding = guess_type(filename, False)
except Exception:
mimeType = None
I'm not sure this is a good method because python does make an
infinite recursion before sending the exception.
Maybe it is better to prevent it, just by using a mutex:
from threading import Lock
guess_type_lock=Lock()
...
with guess_type_lock:
mimeType, mimeEncoding = guess_type(filename, False)
This works fine for me.
Thanks
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev