This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年05月06日 11:43 by gangesmaster, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (4) | |||
|---|---|---|---|
| msg160075 - (view) | Author: ganges master (gangesmaster) | Date: 2012年05月06日 11:43 | |
Attempting to read from stdout of a running process seems broken on Python3.2. I've been able to reproduce this on Ubuntu 11.4 and Windows 7 (with /bin/sh installed as part of git for windows) Python 3.2 (r32:88445, Dec 8 2011, 15:26:51) [GCC 4.5.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from subprocess import Popen, PIPE >>> p=Popen(["/bin/sh"], stdin=PIPE, stderr=PIPE, stdout=PIPE) >>> p.stdin.write(b"echo hello\n") 11 >>> p.stdout.readline() <stuck> >>> from subprocess import Popen, PIPE >>> p=Popen(["/bin/sh"], stdin=PIPE, stderr=PIPE, stdout=PIPE) >>> p.stdin.write(b"echo hello\n") 11 >>> p.stdout.read(2) <stuck> For comparison, on python 2.7 (again, linux and windows: Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24) [GCC 4.5.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from subprocess import Popen, PIPE >>> p=Popen(["/bin/sh"], stdin=PIPE, stderr=PIPE, stdout=PIPE) >>> p.stdin.write(b"echo hello\n") >>> p.stdout.readline() 'hello\n' >>> |
|||
| msg160076 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2012年05月06日 11:55 | |
Works with 3.2.2: Python 3.2.2+ (3.2:9ef20fbd340f, Oct 15 2011, 21:22:07) [GCC 4.5.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from subprocess import Popen, PIPE >>> p=Popen(["/bin/sh"], stdin=PIPE, stderr=PIPE, stdout=PIPE) >>> p.stdin.write(b"echo hello\n") 11 >>> p.stdout.readline() b'hello\n' Try calling p.stdin.flush() perhaps? |
|||
| msg160077 - (view) | Author: ganges master (gangesmaster) | Date: 2012年05月06日 11:59 | |
hmm, it does work when i call flush, but it works perfectly fine without flushing on python2.x... i guess this has to do with str/bytes again. maybe this should be documented somewhere? thanks for the tip though. |
|||
| msg160078 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2012年05月06日 12:04 | |
Nothing to do with str/bytes, actually; I think it was fixed in #11459 (changeset 7451da272111), so you might want to upgrade your Python 3.2 (or use the flush() workaround). |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:29 | admin | set | github: 58942 |
| 2012年05月06日 12:04:42 | pitrou | set | status: open -> closed superseder: Python select.select does not correctly report read readyness messages: + msg160078 resolution: out of date stage: resolved |
| 2012年05月06日 11:59:43 | gangesmaster | set | messages: + msg160077 |
| 2012年05月06日 11:55:39 | pitrou | set | nosy:
+ gregory.p.smith, pitrou messages: + msg160076 |
| 2012年05月06日 11:43:35 | gangesmaster | create | |