Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
7a8d0811
Commit
7a8d0811
authored
Apr 05, 2011
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #11757: subprocess ensures that select() and poll() timeout >= 0
parent
446c8d59
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
14 deletions
+19
-14
Lib/subprocess.py
Lib/subprocess.py
+19
-14
No files found.
Lib/subprocess.py
View file @
7a8d0811
...
...
@@ -817,15 +817,10 @@ class Popen(object):
if
self
.
_communication_started
and
input
:
raise
ValueError
(
"Cannot send input after starting communication"
)
if
timeout
is
not
None
:
endtime
=
time
.
time
()
+
timeout
else
:
endtime
=
None
# Optimization: If we are not worried about timeouts, we haven't
# started communicating, and we have one or zero pipes, using select()
# or threads is unnecessary.
if
(
endtime
is
None
and
not
self
.
_communication_started
and
if
(
timeout
is
None
and
not
self
.
_communication_started
and
[
self
.
stdin
,
self
.
stdout
,
self
.
stderr
].
count
(
None
)
>=
2
):
stdout
=
None
stderr
=
None
...
...
@@ -840,14 +835,18 @@ class Popen(object):
stderr
=
self
.
stderr
.
read
()
self
.
stderr
.
close
()
self
.
wait
()
return
(
stdout
,
stderr
)
else
:
if
timeout
is
not
None
:
endtime
=
time
.
time
()
+
timeout
else
:
endtime
=
None
try
:
stdout
,
stderr
=
self
.
_communicate
(
input
,
endtime
,
timeout
)
finally
:
self
.
_communication_started
=
True
try
:
stdout
,
stderr
=
self
.
_communicate
(
input
,
endtime
,
timeout
)
finally
:
self
.
_communication_started
=
True
sts
=
self
.
wait
(
timeout
=
self
.
_remaining_time
(
endtime
))
sts
=
self
.
wait
(
timeout
=
self
.
_remaining_time
(
endtime
))
return
(
stdout
,
stderr
)
...
...
@@ -1604,8 +1603,11 @@ class Popen(object):
self
.
_input
=
self
.
_input
.
encode
(
self
.
stdin
.
encoding
)
while
self
.
_fd2file
:
timeout
=
self
.
_remaining_time
(
endtime
)
if
timeout
is
not
None
and
timeout
<
0
:
raise
TimeoutExpired
(
self
.
args
,
orig_timeout
)
try
:
ready
=
poller
.
poll
(
self
.
_remaining_time
(
endtime
)
)
ready
=
poller
.
poll
(
timeout
)
except
select
.
error
as
e
:
if
e
.
args
[
0
]
==
errno
.
EINTR
:
continue
...
...
@@ -1664,10 +1666,13 @@ class Popen(object):
stderr
=
self
.
_stderr_buff
while
self
.
_read_set
or
self
.
_write_set
:
timeout
=
self
.
_remaining_time
(
endtime
)
if
timeout
is
not
None
and
timeout
<
0
:
raise
TimeoutExpired
(
self
.
args
,
orig_timeout
)
try
:
(
rlist
,
wlist
,
xlist
)
=
\
select
.
select
(
self
.
_read_set
,
self
.
_write_set
,
[],
self
.
_remaining_time
(
endtime
)
)
timeout
)
except
select
.
error
as
e
:
if
e
.
args
[
0
]
==
errno
.
EINTR
:
continue
...
...
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