Tuesday 15 June 2010

python subprocess Popen hangs -



python subprocess Popen hangs -

opensolaris derivate (nexentastor), python 2.5.5

i've seen numerous examples , many seem indicate problem deadlock. i'm not writing stdin think problem 1 of shell commands exits prematurely.

what's executed in popen is:

ssh <remotehost> "zfs send tank/dataset@snapshot | gzip -9" | gzip -d | zfs recv tank/dataset

in other words, login remote host , (send replication stream of storage volume, pipe gzip) pipe zfs recv write local datastore.

i've seen explanation buffers im not filling those, , gzip bailing out prematurely think process.wait() never gets exit.

process = subprocess.popen(cmd, shell=true, stdout=subprocess.pipe) process.wait() if process.returncode == 0: line in process.stdout: stdout_arr.append([line]) homecoming stdout_arr else: homecoming false

here's happens when run , interrupt it

# ./zfs_replication.py gzip: stdout: broken pipe ^ckilled signal 2. traceback (most recent phone call last): file "./zfs_replication.py", line 155, in <module> exec(zfssendrecv(dataset, today), local) file "./zfs_replication.py", line 83, in exec process.wait() file "/usr/lib/python2.5/subprocess.py", line 1184, in wait pid, sts = self._waitpid_no_intr(self.pid, 0) file "/usr/lib/python2.5/subprocess.py", line 1014, in _waitpid_no_intr homecoming os.waitpid(pid, options) keyboardinterrupt

i tried utilize popen.communicat() method hangs if gzip bail out. in case lastly part of command (zfs recv) exits because local dataset has been modified incremental replication stream not applied, though fixed there has got way of dealing gzips broken pipes?

process = subprocess.popen(cmd, shell=true, stdout=subprocess.pipe) stdout, stderr = process.communicate() if process.returncode == 0: dosomething() else: dosomethingelse()

and when run:

cannot receive incremental stream: destination tank/repl_test has been modified since recent snapshot gzip: stdout: broken pipe ^ckilled signal 2.traceback (most recent phone call last): file "./zfs_replication.py", line 154, in <module> exec(zfssendrecv(dataset, today), local) file "./zfs_replication.py", line 83, in exec stdout, stderr = process.communicate() file "/usr/lib/python2.5/subprocess.py", line 662, in communicate stdout = self._fo_read_no_intr(self.stdout) file "/usr/lib/python2.5/subprocess.py", line 1025, in _fo_read_no_intr homecoming obj.read() keyboardinterrupt

python subprocess zfs opensolaris

No comments:

Post a Comment