Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#16982 closed Bug (duplicate)

Child processes are kept alive when parent dies (with autoreload on)

Reported by: fabiofz@… Owned by: nobody
Component: Core (Other) Version: 1.3
Severity: Normal Keywords: autoreload
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Currently, when the parent process is killed, child processes are still kept alive. I think there should be an option where the child enters a poll mode to know whether the parent process is still alive (and if it's not, the child exits) See: http://stackoverflow.com/questions/284325/how-to-make-child-process-die-after-parent-exits for a reference.

This is especially annoying when working in IDEs that will kill the parent process by default (as opposed to working in the command line, where a ctrl+c is usually the default -- but even in that case, if the process is killed in the task manager instead of doing a ctrl+c, the child process will be kept alive).

After a quick look it seems related to django/utils/autoreload.py and the way it starts up things -- so, it'd be needed to start a thread that keeps seeing if the parent is alive and if it's not it kills the child process.

Or maybe starting the process with some other Popen variant could do the trick too...

Change History (5)

comment:1 by anonymous, 13 years ago

Note: for those with this problem, a workaround (i.e.: always allocating a new console) is available at: http://stackoverflow.com/questions/2746512/pydev-and-django-how-to-restart-dev-server/7648375#7648375 (while this bug isn't properly fixed).

comment:2 by Aymeric Augustin, 13 years ago

Triage Stage: UnreviewedDesign decision needed

I'd prefer to avoid adding another thread to solve a threading problem.

comment:3 by Julien Phalip, 13 years ago

One big issue with process polling is that os.getppid() isn't supported on Windows in Python < 3.2 (see http://hg.python.org/cpython/rev/5d73b036573b/).

comment:4 by Ramiro Morales, 12 years ago

Resolution: duplicate
Status: newclosed

Although #19137 is newer, I'm going to close this one as duplicate because that ticket has an actual patch that looks like a better strategy to solve the issue.

comment:5 by fabiofz@…, 12 years ago

Just to note, if getppid is a problem, take a look at: http://pydev.blogspot.com.br/2013/01/python-get-parent-process-id-pid-in.html on a way to get the parent process id on windows in older versions of python.

Note: See TracTickets for help on using tickets.
Back to Top