﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
3712	Starting other processes in a view gives me some weird results.	Ino Pua <inopua@…>	Adrian Holovaty	"

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."		closed	Core (Other)	dev		duplicate			Unreviewed	0	0	0	0	0	0
