[prev in list] [next in list] [prev in thread] [next in thread]
List: trac
Subject: Re: [Trac] Uploading files for Download
From: Jun Omae <jun66j5 () gmail ! com>
Date: 2015-01-17 13:06:17
Message-ID: CAEVLMai+9-4rZT7=m0aMAWzjivJvHE+3zck84hWAJ+_pSXRPWQ () mail ! gmail ! com
[Download RAW message or body]
<roger.oberholtzer@gmail.com> wrote on 2015-Jan-07 at 08:15 PM:>
File "/usr/lib/python2.7/rfc822.py", line 155, in readheaders
> line = self.fp.readline()
> File "/usr/lib/python2.7/site-packages/trac/web/modpython_frontend.py",
> line 52, in readline
> return self.req.readline(size)
> MemoryError
It seems that to be a mod_python issue. I believe mod_wsgi doesn't
have the issue.
Try to switch mod_wsgi. Otherwise, please try the following patch
(sorry, untested).
diff --git a/trac/web/modpython_frontend.py b/trac/web/modpython_frontend.py
index 60daa89..bddc0ae 100644
--- a/trac/web/modpython_frontend.py
+++ b/trac/web/modpython_frontend.py
@@ -39,6 +39,8 @@ from trac.web.wsgi import WSGIGateway, _ErrorsWrapper
class InputWrapper(object):
+ CHUNK_SIZE = 8192
+
def __init__(self, req):
self.req = req
@@ -49,7 +51,17 @@ class InputWrapper(object):
return self.req.read(size)
def readline(self, size=-1):
- return self.req.readline(size)
+ if size >= 0:
+ return self.req.readline(size)
+ else:
+ # avoid MemoryError when an uploaded file is huge
+ buf = []
+ while True:
+ line = self.req.readline(self.CHUNK_SIZE)
+ buf.append(line)
+ if not line or line.endswith('\n'):
+ break
+ return ''.join(buf)
def readlines(self, hint=-1):
return self.req.readlines(hint)
--
Jun Omae <jun66j5@gmail.com> (大前 潤)
--
You received this message because you are subscribed to the Google Groups "Trac \
Users" group. To unsubscribe from this group and stop receiving emails from it, send \
an email to trac-users+unsubscribe@googlegroups.com. To post to this group, send \
email to trac-users@googlegroups.com. Visit this group at \
http://groups.google.com/group/trac-users. For more options, visit \
https://groups.google.com/d/optout.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic