You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've got hgweb (the Mercurial web app) crashing on guess_type() in
2.6.2, but not in 2.5.4. I'm passing in a filename like
'/home/djc/src/hg/crew/templates/static/hglogo.png'. Doesn't happen on
the REPL, but happens in side the hg serve web server.
Traceback (most recent call last):
File "/home/djc/src/hg/crew/mercurial/hgweb/server.py", line 67, in
do_POST
self.do_write()
File "/home/djc/src/hg/crew/mercurial/hgweb/server.py", line 60, in
do_write
self.do_hgweb()
File "/home/djc/src/hg/crew/mercurial/hgweb/server.py", line 124, in
do_hgweb
for chunk inself.server.application(env, self._start_response):
File "/home/djc/src/hg/crew/mercurial/hgweb/hgwebdir_mod.py", line 91,
in __call__
returnself.run_wsgi(req)
File "/home/djc/src/hg/crew/mercurial/hgweb/hgwebdir_mod.py", line
132, in run_wsgi
return (staticfile(static, fname, req),)
File "/home/djc/src/hg/crew/mercurial/hgweb/common.py", line 73, in
staticfile
ct = mimetypes.guess_type(path)[0] or"text/plain"
File "/usr/lib/python2.6/mimetypes.py", line 244, in guess_typereturn guess_type(url, strict)
(... snip ...)
File "/usr/lib/python2.6/mimetypes.py", line 244, in guess_typereturn guess_type(url, strict)
RuntimeError: maximum recursion depth exceeded
This could well be due to the SocketServer.ThreadingMixIn that's being
used by the hg serve built-in web server (since it doesn't show on REPL
or, as far as I can see, when used from within Apache + mod_wsgi).
The function monkeypatching hack should be replaced with something more
robust.
(what might happen here is that init() is first called from another
thread, sets inited to True and then crashes for whatever reason, so
guess_type() isn't actually monkeypatched)
Activity
djc commentedon Apr 27, 2009
I've got hgweb (the Mercurial web app) crashing on guess_type() in
2.6.2, but not in 2.5.4. I'm passing in a filename like
'/home/djc/src/hg/crew/templates/static/hglogo.png'. Doesn't happen on
the REPL, but happens in side the hg serve web server.
Traceback (most recent call last): File "/home/djc/src/hg/crew/mercurial/hgweb/server.py", line 67, in do_POST self.do_write() File "/home/djc/src/hg/crew/mercurial/hgweb/server.py", line 60, in do_write self.do_hgweb() File "/home/djc/src/hg/crew/mercurial/hgweb/server.py", line 124, in do_hgweb for chunk in self.server.application(env, self._start_response): File "/home/djc/src/hg/crew/mercurial/hgweb/hgwebdir_mod.py", line 91, in __call__ return self.run_wsgi(req) File "/home/djc/src/hg/crew/mercurial/hgweb/hgwebdir_mod.py", line 132, in run_wsgi return (staticfile(static, fname, req),) File "/home/djc/src/hg/crew/mercurial/hgweb/common.py", line 73, in staticfile ct = mimetypes.guess_type(path)[0] or "text/plain" File "/usr/lib/python2.6/mimetypes.py", line 244, in guess_type return guess_type(url, strict) (... snip ...) File "/usr/lib/python2.6/mimetypes.py", line 244, in guess_type return guess_type(url, strict) RuntimeError: maximum recursion depth exceededdjc commentedon Apr 27, 2009
georg.brandl remarked it might be due to demandimport. That doesn't seem
to be the case:
djc commentedon Apr 27, 2009
This could well be due to the SocketServer.ThreadingMixIn that's being
used by the hg serve built-in web server (since it doesn't show on REPL
or, as far as I can see, when used from within Apache + mod_wsgi).
pitrou commentedon Apr 27, 2009
The function monkeypatching hack should be replaced with something more
robust.
(what might happen here is that init() is first called from another
thread, sets
initedto True and then crashes for whatever reason, soguess_type() isn't actually monkeypatched)
pitrou commentedon Apr 27, 2009
The plan is to replace init() with something like:
and guess_type() with:
(same for other functions)
pitrou commentedon Apr 27, 2009
In the meantime, hgweb could probably call mimetypes.init() at the
beginning (before spawning threads).
pitrou commentedon Apr 27, 2009
For the record, here is a test script showcasing the problem.
pitrou commentedon Apr 27, 2009
Committed a fix in r72045. Thanks for the report!