django subprocess doesnt like sleep

33 views
Skip to first unread message

dk

unread,
Jun 5, 2015, 11:44:15 AM6/5/15
to django...@googlegroups.com
I created a website that can reboot a machine. basically subprocess a script that lunch the reboot command in Linux.
after that  I need to run some other operations. after that I wait 1 minute before start pinging the machine to see if its back online.

the funny thing my script doesn't work, and I found out that django doesn't like to wait more than 24 secs. =(  I might be doing something wrong?  If I do more than 25 the process just stops at the time.sleep(60) and nothing happen afterwards.  if I do it for 24 secs everything run fine.  

is there any special thing that I should know?

dk

unread,
Jun 5, 2015, 12:34:27 PM6/5/15
to django...@googlegroups.com
this is what I got from putting
    time.sleep(60)
    print "sleeped for 60secs"
    print 6
directly in the view.
and this is what the httpd log gave me.

[Fri Jun 05 11:31:02.034913 2015] [mpm_prefork:notice] [pid 33231] AH00170: caught SIGWINCH, shutting down gracefully
[Fri Jun 05 16:31:02.046665 2015] [:error] [pid 33304] sleeped for 60secs
[Fri Jun 05 16:31:02.046702 2015] [:error] [pid 33304] 6

why is shutting down gracefully, what does it mean? that killed to process?  why?    can this be happening to my subprocess?

Vijay Khemlani

unread,
Jun 5, 2015, 12:42:39 PM6/5/15
to django...@googlegroups.com
I don't think you should be doing that kind of work in the web server process. 

If you want to run a task that may take a long time to finish then use celery or something like that.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/222a147f-1771-43f7-8b0c-621819cfb89e%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Tom Lockhart

unread,
Jun 5, 2015, 3:24:06 PM6/5/15
to django...@googlegroups.com
That is a long delay for an http request/response cycle.

If you do not already, you may want to model the remote machine state in a Django model. Use that to monitor and update the machine states and then your client-facing interactions can be decoupled from it.

You can use a subprocess or celery to do the extended work as required.

hth

- Tom

dk

unread,
Jun 5, 2015, 3:27:14 PM6/5/15
to django...@googlegroups.com
mmmm....
some one put in contab -e
* * * * * systemctl resetart httpd

means that every minute the apache server is restarting and killing everything. that's why non of the script where working =(.... 
now that I commented that line from cron tab its working =).

Reply all
Reply to author
Forward
0 new messages