Replying myself to add some information and ask some extra questions. I just had contact with the maintainer of my shared host. He warned that memory exceeding the (shared usage) limit could cause strange errors. And that memory usage should be dealt with carefully. He adviced me to save the uploaded files directly to disk instead of storing them in memory first. Can I do this at all with Django?
I am now using (in the view) if request.method == 'POST': if 'uploadedfile' in request.FILES: new_data = request.POST.copy() new_data.update(request.FILES) form = UploadForm(new_data) if form.is_valid(): success = form.save(request.user) in the UploadForm class def clean_uploadedfile(self): file_data = self.clean_data['uploadedfile'] .... return file_data in save() if self.clean_data['uploadedfile']: uploadedfile_data = self.clean_data['uploadedfile'] file_path = "path/to/saved/file/%s" % (uploadedfile_data['filename']) save_content_to_file(file_path, uploadedfile_data['content']) and only finally in save_content_to_file() def save_content_to_file(filename, content): try: fileObj = open(filename, "wb") try: fileObj.write(content) finally: fileObj.close() So I am guessing I'm consuming quite some memory to deal with this incoming request data. How could I improve my code, so it will use its memory a bit more economically? And is there a way to have the files in the requested post data streamed into files on disk directly? Thanks, dirk On 26-jun-2007, at 17:36, Dirk van Oosterbosch, IR labs wrote: > Hi All, > > I deployed an app with uploading functionality to a server running > FastCGI. > When I had it tested by my users, the site became completely > unresponsive, returning nothing but Error 500's. > > In the log I find a lot of these: > Unhandled exception in thread started by <bound method > ThreadPool._worker of <flup.server.threadpool.ThreadPool object at > 0x825e10>> > Traceback (most recent call last): > File "/usr/local/lib/python2.5/site-packages/flup-0.5-py2.5.egg/ > flup/server/threadpool.py", line 103, in _worker > job.run() > File "/usr/local/lib/python2.5/site-packages/flup-0.5-py2.5.egg/ > flup/server/fcgi_base.py", line 645, in run > except (select.error, socket.error), e: > AttributeError: 'NoneType' object has no attribute 'error' > > Does anybody know, what could cause this or (better yet) how to fix > it? > best > dirk ----------------------------- Dirk van Oosterbosch de Wittenstraat 225 1052 AT Amsterdam the Netherlands http://labs.ixopusada.com ----------------------------- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---