Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
2fa9aa01
Commit
2fa9aa01
authored
Jun 16, 2015
by
Jason Madden
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #542 from romuald/popen-bufsize
subprocess.Popen `bufsize` option actually used
parents
15992102
ff230fb4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
5 deletions
+15
-5
gevent/subprocess.py
gevent/subprocess.py
+5
-5
greentest/test__subprocess.py
greentest/test__subprocess.py
+10
-0
No files found.
gevent/subprocess.py
View file @
2fa9aa01
...
@@ -247,17 +247,17 @@ class Popen(object):
...
@@ -247,17 +247,17 @@ class Popen(object):
errread
=
msvcrt
.
open_osfhandle
(
errread
.
Detach
(),
0
)
errread
=
msvcrt
.
open_osfhandle
(
errread
.
Detach
(),
0
)
if
p2cwrite
is
not
None
:
if
p2cwrite
is
not
None
:
self
.
stdin
=
FileObject
(
p2cwrite
,
'wb'
)
self
.
stdin
=
FileObject
(
p2cwrite
,
'wb'
,
bufsize
)
if
c2pread
is
not
None
:
if
c2pread
is
not
None
:
if
universal_newlines
:
if
universal_newlines
:
self
.
stdout
=
FileObject
(
c2pread
,
'rU'
)
self
.
stdout
=
FileObject
(
c2pread
,
'rU'
,
bufsize
)
else
:
else
:
self
.
stdout
=
FileObject
(
c2pread
,
'rb'
)
self
.
stdout
=
FileObject
(
c2pread
,
'rb'
,
bufsize
)
if
errread
is
not
None
:
if
errread
is
not
None
:
if
universal_newlines
:
if
universal_newlines
:
self
.
stderr
=
FileObject
(
errread
,
'rU'
)
self
.
stderr
=
FileObject
(
errread
,
'rU'
,
bufsize
)
else
:
else
:
self
.
stderr
=
FileObject
(
errread
,
'rb'
)
self
.
stderr
=
FileObject
(
errread
,
'rb'
,
bufsize
)
def
__repr__
(
self
):
def
__repr__
(
self
):
return
'<%s at 0x%x pid=%r returncode=%r>'
%
(
self
.
__class__
.
__name__
,
id
(
self
),
self
.
pid
,
self
.
returncode
)
return
'<%s at 0x%x pid=%r returncode=%r>'
%
(
self
.
__class__
.
__name__
,
id
(
self
),
self
.
pid
,
self
.
returncode
)
...
...
greentest/test__subprocess.py
View file @
2fa9aa01
...
@@ -159,6 +159,16 @@ class Test(greentest.TestCase):
...
@@ -159,6 +159,16 @@ class Test(greentest.TestCase):
else
:
else
:
raise
AssertionError
(
'must fail with CalledProcessError'
)
raise
AssertionError
(
'must fail with CalledProcessError'
)
def
test_popen_bufsize
(
self
):
# Test that subprocess has unbuffered output by default
# (as the vanilla subprocess module)
p
=
subprocess
.
Popen
([
sys
.
executable
,
'-u'
,
'-c'
,
'import sys; sys.stdout.write(sys.stdin.readline())'
],
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
)
p
.
stdin
.
write
(
'foobar
\
n
'
)
r
=
p
.
stdout
.
readline
()
self
.
assertEqual
(
r
,
'foobar
\
n
'
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
greentest
.
main
()
greentest
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment