memory - MemoryError in python with chunked uploading -
i writing server side chunked uploading files. got memoryerror , can`t understand doing wrong. here python code(with framework pyramid):
@view_config(route_name='fileupload',renderer='../upload.mako') def upload_file(request): session = request.session if 'authorized' in session , session['authorized'] false: return httpforbidden() try: filename = request.params.get('filename') print request.params.get('chunkindex') datatmp = request.params.get('data') data64 = datatmp[13:] data = base64.b64decode(data64) f = open('/home/somedirectory/' + filename , 'ab') f.write(data) f.close() except exception e: print e return {}
error traceback:
2015-07-24 17:57:36,630 error [waitress][dummy-5 340] exception when serving /upload traceback (most recent call last): file "/home/myusername/project25/local/lib/python2.7/site- packages/waitress-0.8.9-py2.7.egg/waitress/channel.py", line 337, in service task.service() file "/home/myusername/project25/local/lib/python2.7/site-packages/waitress-0.8.9-py2.7.egg/waitress/task.py", line 173, in service self.execute() file "/home/myusername/project25/local/lib/python2.7/site-packages/waitress-0.8.9-py2.7.egg/waitress/task.py", line 392, in execute app_iter = self.channel.server.application(env, start_response) file "/home/myusername/project25/local/lib/python2.7/site-packages/pyramid-1.5.6-py2.7.egg/pyramid/router.py", line 242, in __call__ response = self.invoke_subrequest(request, use_tweens=true) file "/home/myusername/project25/local/lib/python2.7/site-packages/pyramid-1.5.6-py2.7.egg/pyramid/router.py", line 217, in invoke_subrequest response = handle_request(request) file "/home/myusername/project25/local/lib/python2.7/site-packages/pyramid_debugtoolbar-2.3-py2.7.egg/pyramid_debugtoolbar/toolbar.py", line 168, in toolbar_tween toolbar = debugtoolbar(request, panel_classes, global_panel_classes) file "/home/myusername/project25/local/lib/python2.7/site-packages/pyramid_debugtoolbar-2.3-py2.7.egg/pyramid_debugtoolbar/toolbar.py", line 49, in __init__ panel_inst = panel_class(request) file "/home/myusername/project25/local/lib/python2.7/site-packages/pyramid_debugtoolbar-2.3-py2.7.egg/pyramid_debugtoolbar/panels/request_vars.py", line 30, in __init__ k in request.post], file "/usr/lib/python2.7/pprint.py", line 67, in saferepr return _safe_repr(object, {}, none, 0)[0] file "/usr/lib/python2.7/pprint.py", line 323, in _safe_repr rep = repr(object) memoryerror
pyramid debugtoolbar raising exception while trying render variables in post request.
you have enabled in development environments, disable running application production.ini. evaluate if behaviour different.
btw: run pyramid tutorial on authentication protect view authenticated users, not swallow exceptions way , use logging statement instead of printing. pyramid docs/tuts apply these techniques.
Comments
Post a Comment