Code

Opened 6 years ago

Closed 5 years ago

Last modified 3 years ago

#9286 closed (worksforme)

Starting other processes in a view gives me some weird results.

Reported by: namename12 Owned by: nobody
Component: Uncategorized Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by kmtracey)

I cannot start process as daemon.

This error is similar to this thread:
http://groups.google.com/group/django-users/browse_thread/thread/2d2e20ccd394297b?pli=1

Django hangs when I execute this code:

def start(request):
        if request.user.is_authenticated():
                output = Popen(["/usr/local/tomcat/bin/jboss.sh"], stdout=PIPE).communicate()[0]
                foo ="a"
                return render_to_response('cms/templates/list.html', {'logs': foo})

        else:
                return HttpResponseRedirect("/accounts/login")

Attachments (0)

Change History (7)

comment:1 Changed 6 years ago by namename12

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

def start(request):<br>

if request.user.is_authenticated():<br>

output = Popen(usr/local/tomcat/bin/startup.sh?, stdout=PIPE).communicate()[0]<br>
foo ="a"<br>
return render_to_response('cms/templates/list.html', {'logs': foo})<br>

else:<br>

return HttpResponseRedirect("/accounts/login")<br>

comment:2 Changed 6 years ago by kmtracey

  • Description modified (diff)

comment:3 Changed 5 years ago by jacob

  • milestone set to 1.1
  • Triage Stage changed from Unreviewed to Accepted

comment:4 Changed 5 years ago by jacob

  • Resolution set to worksforme
  • Status changed from new to closed

I'm not sure this is a bug at all. That is, Popen.communicate() is supposed to block until stdin reaches EOF (http://docs.python.org/library/subprocess.html#subprocess.Popen.communicate). And that's exactly what happens when I spawn processes from a Django view: when the process completes, so does the view.

comment:5 Changed 5 years ago by stevecrozz@…

  • Resolution worksforme deleted
  • Status changed from closed to reopened

I'd call this a bug, and its affecting me.

The django development server is able to start a background process, but for some reason it must block until the sub process dies. Place something like this in a view and you'll get your response 5 seconds later, Popen.communicate() is not needed to reproduce it:

subprocess.Popen(['/bin/sleep', '5'])
return HttpResponse(u'That sure took a while!')

Also see #4953 and #3712

comment:6 Changed 5 years ago by Alex

  • Resolution set to worksforme
  • Status changed from reopened to closed

This bug was closed by a core developer, if you disagree please bring this up for discussion ont he django-development mailiing list.

comment:7 Changed 3 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.