Skip to contentSkip to conversation

xend: use popen2 module instead of subprocess for Python 2.3

RFC PATCH In review KUWAMURA Shin'ya 2 participants 3 messages May 29, 2009 – Jun 2, 2009

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 xend: use popen2 module instead of subprocess for Python 2.3

Hi,

On Python 2.3, xend cannot started:
File "usr/lib/python2.3/site-packages/xen/xend/server/BlktapController.py", line 3, in ?
import subprocess
ImportError: No module named subprocess

This patch uses popen2' instead of subprocess' for Python 2.3. However, I tested only 'xend start'.
Is this correct?
And, is Python 2.3 still supported?

Signature · 1 line
  KUWAMURA Shin'ya

# HG changeset patch
# User KUWAMURA Shin'ya <[email protected]>
# Date 1243574978 -32400
# Node ID 006107c3d953ab8e5803e793db9cb7ef99487c15 # Parent 9e72be06ac4be008f2e673ce11ef86c346e34faa
xend: use popen2 module instead of subprocess for Python 2.3

The module subprocess' was introduced in Python 2.4. This patch uses popen2' instead of `subprocess' for Python 2.3.

tools/python/xen/xend/server/BlktapController.py +7 -4
diff -r 9e72be06ac4b -r 006107c3d953 tools/python/xen/xend/server/BlktapController.py
@@ -1,6 +1,6 @@
 # Copyright (c) 2005, XenSource Ltd.
 import string, re
-import subprocess
+import popen2
 
 from xen.xend.server.blkif import BlkifController
 from xen.xend.XendLogging import log
@@ -27,9 +27,12 @@ blktap_disk_types = [
  
 def doexec(args, inputtext=None):
     """Execute a subprocess, then return its return code, stdout and stderr"""
-    proc = subprocess.Popen(args,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,close_fds=True)
-    (stdout,stderr) = proc.communicate(inputtext)
-    rc = proc.returncode
+    proc = popen2.Popen3(args, True)
+    if inputtext != None:
+        proc.tochild.write(inputtext)
+    stdout = proc.fromchild
+    stderr = proc.childerr
+    rc = proc.poll()
     return (rc,stdout,stderr)
 
 def parseDeviceString(device):

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

KUWAMURA Shin'ya writes ("[Xen-devel] [PATCH] [RFC] xend: use popen2 module instead of subprocess for Python 2.3"):

Quoted 6 lines

On Python 2.3, xend cannot started:
File "usr/lib/python2.3/site-packages/xen/xend/server/BlktapController.py", line 3, in ?
import subprocess
ImportError: No module named subprocess

This patch uses popen2' instead of subprocess' for Python 2.3.

It looks broadly correct to me, although I haven't tested it.

Quoted 1 line

However, I tested only 'xend start'.

Did you test it with a blktap block device ?

Quoted 1 line

And, is Python 2.3 still supported?

I think we would try to make it continue to work unless this is particularly difficult for some reason.

Thanks,
Ian.

#2 lore raw

Hi,

Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

On Fri, 29 May 2009 17:51:44 +0100
[email protected](Ian Jackson) said:

KUWAMURA Shin'ya writes ("[Xen-devel] [PATCH] [RFC] xend: use popen2 module instead of subprocess for Python 2.3"):

Quoted 1 line

However, I tested only 'xend start'.

Did you test it with a blktap block device ?

I could not test blktap. I got the following error using tap:aio:
File "usr/lib/python2.3/site-packages/xen/xend/server/BlktapController.py", line 124, in createDevice
(typ, subtyp, params, file) = string.split(uname, ':', 3)
ValueError: unpack list of wrong size

Thus, I could not test it.

Quoted 4 lines
Quoted 1 line

And, is Python 2.3 still supported?

I think we would try to make it continue to work unless this is particularly difficult for some reason.

OK. I use Python 2.3 for a while.

Best regards,

Signature · 1 line
  KUWAMURA Shin'ya