473,287 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Running programs under a python program...

So I have a python program that runs a bunch of other programs....it
then loops forever, occasionally executing other programs.

To run each of these programs my python code executes:
subprocess.Popen(command_line, shell=True, stdout=fd,
stderr=subprocess.STDOUT)

where command_line is an appropriate command line. :)

Now my problem is when I abort this program it kills off all the child
processes I've started. In this case I don't want that. How can I
stop the child processes from dieing when I kill off the parent?

Thanks!
Jun 27 '08 #1
2 1191
maybe you could instead of killing the program stop the loop that starts
new processes and start one that runs until the last process ends?

also, if you killed the program but stdout was still set to fd and stderr
was still set to subprocesses.STDOUT, what would happen when those two
objects disappeared? wouldn't the processes crash or something?

i dunno much about this though, maybe there's some way

<sa*******@gmail.comwrote in message
news:43**********************************@t12g2000 prg.googlegroups.com...
So I have a python program that runs a bunch of other programs....it
then loops forever, occasionally executing other programs.

To run each of these programs my python code executes:
subprocess.Popen(command_line, shell=True, stdout=fd,
stderr=subprocess.STDOUT)

where command_line is an appropriate command line. :)

Now my problem is when I abort this program it kills off all the child
processes I've started. In this case I don't want that. How can I
stop the child processes from dieing when I kill off the parent?

Thanks!

Jun 27 '08 #2
sa*******@gmail.com <sa*******@gmail.comwrote:
So I have a python program that runs a bunch of other programs....it
then loops forever, occasionally executing other programs.

To run each of these programs my python code executes:
subprocess.Popen(command_line, shell=True, stdout=fd,
stderr=subprocess.STDOUT)

where command_line is an appropriate command line. :)

Now my problem is when I abort this program it kills off all the child
processes I've started. In this case I don't want that. How can I
stop the child processes from dieing when I kill off the parent?
It depends on why the children are dying.

From what you say, it seems likely that they're trying to write to
their standard output, and exiting because that's a pipe that is now
closed.

If that's the case, it's probably best to start by deciding where you
want that output to go when the parent process has ended. Perhaps you
can just send it all to a log file in the first place.

-M-

Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Colin Brown | last post by:
As I am getting a larger collection of python program packages the idea of saving them as zips is becoming increasingly attractive. The latest idea is to launch them from a generic wrapper listed...
5
by: Shalen chhabra | last post by:
Hey, Can anyone give me a snippet for running a python program over all the files in the directory. For ex: I have ten files in a directory and I want to run a python program against all of...
1
by: Mathias Dahl | last post by:
I am creating a small app called PyQe (http://klibb.com/cgi-bin/wiki.pl/PyQe) to launch commands and programs quickly. I works more or less as I want it now and I have managed to make my window...
9
by: Matt Helm | last post by:
I am starting the design phase of a large project (ERP) where the backend will mostly be Python (or Ruby) providing web services. In this type of usage, is there any benenfit to running under...
3
by: James Stroud | last post by:
Hello All, I am helping someone write a python script to run their DOS application through an SSH terminal. It seems that this program wants to access a DOS shell and send output there. If...
13
by: John Salerno | last post by:
If I want to write my code in a separate text editor (I like UltraEdit) but then press a single button to have that code run in the IDLE environment, is that possible? I know that you can configure...
20
by: Guy Fawkes | last post by:
Hi, I was wondering if Python programs always need to include the source code with the program itself. I'm asking this because I don't want my program to be open-source and so far all the Python...
3
by: Josh Volz | last post by:
Hi everyone: I have a spider that is relatively long running (somewhere between 12-24 hours). My problem is that I keep having an issue where the program appears to freeze. Once this freezing...
9
by: Jimmy | last post by:
Well, i know it may be a little non-python thing, however, I can think of no place better to post this question :) can anyone tell me, in python, how to obtain some information of a running...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.