Hi all,

I'm using the code below to stream the response of an external command to
the user. While that is all working fine, I would like to be able to react
to the user closing the browser or hitting ESC by terminating the external
process.

When using the development server, I get a 'broken pipe' exception when
hitting ESC while loading the page, but I'm not sure how to react to that
exxception... Is there any way to register some kind of shutdown handler
that gets executed when the connection to the client dies?

Or is there a better way to stream the response of an external command to
the client and have the command terminate when the socket goes away?

My streaming code:

def fetch(request):
  stdin, stdout = os.popen2('cmd')
  stdin.close()
  return HttpResponse(stdout)

Cheers,

        Marcus

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to