30 Aug, 2008
If you choose to host a set of mercurial repositories using mod_wsgi you will probably his this exception:
mod_wsgi (pid=2189): Exception occurred processing WSGI script 'script/hgweb.wsgi'. Traceback (most recent call last): File "python2.5/site-packages/mercurial/hgweb/hgwebdir_mod.py", line 73, in __call__ return self.run_wsgi(req) File "python2.5/site-packages/mercurial/hgweb/hgwebdir_mod.py", line 98, in run_wsgi req.write(self.makeindex(req, tmpl)) File "python2.5/site-packages/mercurial/hgweb/request.py", line 84, in write for part in thing: File "python2.5/site-packages/mercurial/templater.py", line 137, in __call__ item = iters[0].next() File "python2.5/site-packages/mercurial/templater.py", line 120, in _process for i in v: File "python2.5/site-packages/mercurial/hgweb/hgwebdir_mod.py", line 175, in entries u.warn(_('error reading %s/.hg/hgrc: %s\\n' % (path, e))) File "python2.5/site-packages/mercurial/ui.py", line 443, in warn self.write_err(*msg) File "python2.5/site-packages/mercurial/ui.py", line 386, in write_err if not sys.stdout.closed: sys.stdout.flush() IOError: sys.stdout access restricted by mod_wsgi
If you just change these lines in mercurial/ui.py around 386 from this:
def write_err(self, *args): try: if not sys.stdout.closed: sys.stdout.flush() for a in args: sys.stderr.write(str(a)) # stderr may be buffered under win32 when redirected to files, # including stdout. if not sys.stderr.closed: sys.stderr.flush() except IOError, inst: if inst.errno != errno.EPIPE: raise
So that the Except clause at the end looks like this:
except IOError, inst: if not (inst.errno == errno.EPIPE or "access restricted by mod_wsgi" in str(inst)): raise
Then everything seems to work nicely.
Copyright James Gardner 1996-2020 All Rights Reserved. Admin.