Opened 18 years ago
Closed 16 years ago
#3712 closed (duplicate)
Starting other processes in a view gives me some weird results.
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Quick way of reproducing:
- Start a new project
- 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), )
- Start the django server (
python manage.py runserver 8080
) - 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.
- 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.
Change History (6)
comment:1 by , 18 years ago
comment:2 by , 18 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
IMHO this belongs in the django-users mailing list.
comment:4 by , 17 years ago
Ino Pua's thread is at http://groups.google.com/group/django-users/browse_thread/thread/2d2e20ccd394297b
comment:5 by , 16 years ago
Resolution: | invalid |
---|---|
Status: | closed → reopened |
Heading
Environment:
Request Method: GET
Request URL: http://IP:8080/stop/
Django Version: 1.0-final-SVN-unknown
Python Version: 2.4.4
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'mysite.s1']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware')
Traceback:
File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py" in get_response
- response = callback(request, *callback_args, callback_kwargs)
File "/home/user/Django-1.0/django/bin/mysite/../mysite/urls.py" in stop
- cmdname = requestcmd
Exception Type: TypeError at /stop/
Exception Value: unsubscriptable object
Subheading
comment:6 by , 16 years ago
Resolution: | → duplicate |
---|---|
Status: | reopened → closed |
Appears to be a duplicate of #9286 and since that's already open, I'm reclosing this one (the other ticket has more information available). If you have new information to help diagnosing #9286, please add it there (but use the "preview" button first and fix the formatting, since your comment here is unreadable). If you are just indicating that you also see the problem, there's not much point adding a comment, since we already know the issue exists.
Remember to start the server (python manage.py runserver) as root if you're using /etc/init.d-scripts to start and stop daemons ;)