This should work. Nice idea.

On Jan 24, 5:00 am, jlegler <jleg...@gmail.com> wrote:
> This is more of a general python question but maybe someone here knows
> if my idea will work or not.  I want my function to tell me when it is
> done running.  Currently I return the stream so there is no obvious
> way to run code after it returns a value.  I am wondering if I do a
> try: finally: statement though if I can call a function as the return
> statement completes.  For instance, the following code returns a
> stream and then in the finally clause, it calls a function called
> complete.  Does anyone know if this is an acceptable practice?
>
> def stream():
>     import os
>     if len(request.args):
>         title_id = int(request.args[0])
>         filename = db(db.content.id == title_id).select()
> [0].filename.replace('.mpi','.mp4')
>         path = os.path.join(request.folder,'static','video',filename)
>         response.headers['ContentType']="video/mp4"
>         try:
>             return response.stream(open(path),chunk_size=4096)
>         finally:
>             complete()
>     else:
>         redirect(URL(request.application,'default','index'))

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to