When the post request comes in to index, the session file gets locked, 
which blocks all subsequent requests. The reason the upload progress bar 
still works is that you hacked into copystream_progress, which is called 
before the session file is locked. However, once the file has uploaded, the 
index function gets executed, and by that point, the session file has been 
locked, which therefore blocks the Ajax calls you are making for the 
encoding progress bar. To get around that, you can unlock the session file:

def index():
    upload_form = SQLFORM(db.encodeupload)
    if upload_form.validate():
        session._unlock(response)
        [while loop checking to see if file encoding is complete]
        db.encodeupload.insert(**form.vars)
    [rest of code]

Note, the only danger with this is that it could result in a race condition 
with the session -- if the user opens another tab/window to a URL that 
writes to the session, that session write would get clobbered by this one 
once the encoding/submission is complete.

Also, in the controller action that you call for the encoding progress bar, 
you might want to do session.forget(response) so it doesn't lock or write 
to the session either.

Anthony

On Thursday, June 14, 2012 2:01:06 AM UTC-4, Charles Tang wrote:
>
> This does prevent the submit but the index.html view which display the 
> uploading and encoding progress is not active anymore since index.html 
> contains ajax query to a controller reporting the uploading progress.
>  
> On Thursday, June 14, 2012 12:11:11 PM UTC+8, Anthony wrote:
>>
>> I see. Do you want the form processing action to simply wait until the 
>> file is processed before doing the insert and returning? In that case, you 
>> might use this approach: 
>> http://web2py.com/books/default/chapter/29/7#SQLFORM-without-database-IO?
>>
>> def index():
>>     upload_form = SQLFORM(db.encodeupload)
>>     if  upload_form.validate():
>>         [while loop checking to see if file encoding is complete]
>>         db.encodeupload.insert(**form.vars)
>>     [rest of code]
>>
>> Anthony
>>
>> On Wednesday, June 13, 2012 11:24:09 PM UTC-4, Charles Tang wrote:
>>>
>>> I did some hacking in the copystream in gluon/main.py and begin encoding 
>>> with ffmpeg from the temporary file onece it detect video upload is happen.
>>>
>>

Reply via email to