subprocess.Popen

M

Michele Simionato

I was looking at Python 2.4 subprocess.Popen. Quite nice and handy, but I
wonder why a "kill" method is missing. I am just adding it via subclassing,

class Popen(subprocess.Popen):
def kill(self, signal = SIGTERM):
os.kill(self.pid, signal)

but I would prefer to have it in the standard Popen class. I am surprised
it is not there. Any comments?

Michele Simionato
 
P

Peter Hansen

Michele said:
I was looking at Python 2.4 subprocess.Popen. Quite nice and handy, but I
wonder why a "kill" method is missing. I am just adding it via subclassing,

class Popen(subprocess.Popen):
def kill(self, signal = SIGTERM):
os.kill(self.pid, signal)

but I would prefer to have it in the standard Popen class. I am surprised
it is not there. Any comments?

Likely this is at least part of the answer:

c:\>python
Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on
win32Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'module' object has no attribute 'kill'


Note the "on win32" part above...

-Peter
 
K

Keith Dart

Michele said:
I was looking at Python 2.4 subprocess.Popen. Quite nice and handy, but I
wonder why a "kill" method is missing. I am just adding it via subclassing,

class Popen(subprocess.Popen):
def kill(self, signal = SIGTERM):
os.kill(self.pid, signal)

but I would prefer to have it in the standard Popen class. I am surprised
it is not there. Any comments?

Probably because it is not entirely portable. If you want a more
complete, but Posix-only (at least Linux and FreeBSD), process
management and spawning then you can use the proctools module in pyNMS.

http://sourceforge.net/projects/pynms/





--
\/ \/
(O O)
-- --------------------oOOo~(_)~oOOo----------------------------------------
Keith Dart <[email protected]>
vcard: <http://www.kdart.com/~kdart/kdart.vcf>
public key: ID: F3D288E4 URL: <http://www.kdart.com/~kdart/public.key>
============================================================================
 
K

Keith Dart

Keith said:
Probably because it is not entirely portable. If you want a more
complete, but Posix-only (at least Linux and FreeBSD), process
management and spawning then you can use the proctools module in pyNMS.

http://sourceforge.net/projects/pynms/

I forgot to mention that the pyNMS package also has a module called
"expect" that works like the Expect language. You can interact and
control interactive processes and external CLIs with it.




--
\/ \/
(O O)
-- --------------------oOOo~(_)~oOOo----------------------------------------
Keith Dart <[email protected]>
vcard: <http://www.kdart.com/~kdart/kdart.vcf>
public key: ID: F3D288E4 URL: <http://www.kdart.com/~kdart/public.key>
============================================================================
 
P

P

Michele said:
I was looking at Python 2.4 subprocess.Popen. Quite nice and handy, but I
wonder why a "kill" method is missing. I am just adding it via subclassing,

class Popen(subprocess.Popen):
def kill(self, signal = SIGTERM):
os.kill(self.pid, signal)

but I would prefer to have it in the standard Popen class. I am surprised
it is not there. Any comments?

Seems like an ommission, but probably due
to windows implementation problems?

Note my subprocess.py that was referenced
in pep 324 does have a kill method:
http://www.pixelbeat.org/libs/subProcess.py
Note also that it also kills any children
of the subProcess using process groups.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top