I'm working on a web.py app for uploading files and im having real problems with my deployment. Basically I want to give the user a 'percentage uploaded' but this seems to be messing up severely when deployed on mod_wsgi. The main upload works like this:
out = open(path, 'wb', 1000)
while (True):
packet = fileU.file.read(1000)
if not packet:
break
else:
out.write(packet)
sessions[code].progress += 1
out.close()
'Session' is a global dictionary that contains objects that keep track of sessions. To get the current progress I get the current progress for a given session via a GET request from the client every second.
The problem at the moment is that this only works for small uploads. It seems that anything over around 100kb will just not increment the progress variable. The value is definitely incremented if placed outside of the loop (or before read() is ever called) or if the file is fairly small.
Is it possible that wsgi is opening new threads for bigger files and therefore making my global counter only local to the upload thread? Could it be something else.