#3712: Starting other processes in a view gives me some weird results.
---------------------------------------+------------------------------------
Reporter:  Ino Pua <[EMAIL PROTECTED]>  |       Owner:  adrian        
  Status:  new                         |   Component:  Core framework
 Version:  SVN                         |    Keywords:                
   Stage:  Unreviewed                  |   Has_patch:  0             
---------------------------------------+------------------------------------
 Quick way of reproducing:
 
  1. Start a new project
  2. Replace urls.py with:
 
 {{{
 from django.conf.urls.defaults import *
 from django.http import HttpResponse
 import subprocess
 
 
 def start(request):
     cmdname = request['cmd']
     p = subprocess.Popen([cmdname, 'start'], stdout=subprocess.PIPE)
     stdout, stderr = p.communicate()
     return HttpResponse(stdout or stderr)
 
 def stop(request):
     cmdname = request['cmd']
     p = subprocess.Popen([cmdname, 'stop'], stdout=subprocess.PIPE)
     stdout, stderr = p.communicate()
     return HttpResponse(stdout or stderr)
 
 urlpatterns = patterns('',
     (r'start/$', start),
     (r'stop/$', stop),
 )
 }}}
 
  3. Start the django server ({{{python manage.py runserver 8080}}})
  4. Access an url like:
 http://localhost:8080/start/?cmd=/etc/init.d/exim4, or any cmd= that
 starts a service (anything that daemonizes). You'll notice that the
 loading bar (in my firefox at least) never stops loading, even though the
 django web server is done with the request, and the page has been
 rendered.
  5. If you now stop the server and try to start it again, it wont be able
 to bind to its port:
 
 {{{
 Validating models...
 0 errors found.
 
 Django version 0.96-pre, using settings 'starter.settings'
 Development server is running at http://127.0.0.1:8080/
 Quit the server with CONTROL-C.
 Error: (48, 'Address already in use')
 }}}
 
 However, at this time, Im not sure whats causing this to happen. Any ideas
 would be appreciated.
 
 Shutting the started service down manually, or accessing the /stop/?cmd=
 url before stopping the django server fixes the problem.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/3712>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to