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
2e413f7c
Commit
2e413f7c
authored
May 13, 2016
by
Yury Selivanov
Browse files
Options
Browse Files
Download
Plain Diff
Merge 3.5 (asyncio)
parents
8308db5c
5dc09333
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
4 deletions
+45
-4
Lib/asyncio/unix_events.py
Lib/asyncio/unix_events.py
+10
-4
Lib/test/test_asyncio/test_events.py
Lib/test/test_asyncio/test_events.py
+35
-0
No files found.
Lib/asyncio/unix_events.py
View file @
2e413f7c
...
...
@@ -329,14 +329,17 @@ class _UnixReadPipeTransport(transports.ReadTransport):
elif
self
.
_closing
:
info
.
append
(
'closing'
)
info
.
append
(
'fd=%s'
%
self
.
_fileno
)
if
self
.
_pipe
is
not
None
:
selector
=
getattr
(
self
.
_loop
,
'_selector'
,
None
)
if
self
.
_pipe
is
not
None
and
selector
is
not
None
:
polling
=
selector_events
.
_test_selector_event
(
sel
f
.
_loop
.
_sel
ector
,
selector
,
self
.
_fileno
,
selectors
.
EVENT_READ
)
if
polling
:
info
.
append
(
'polling'
)
else
:
info
.
append
(
'idle'
)
elif
self
.
_pipe
is
not
None
:
info
.
append
(
'open'
)
else
:
info
.
append
(
'closed'
)
return
'<%s>'
%
' '
.
join
(
info
)
...
...
@@ -454,9 +457,10 @@ class _UnixWritePipeTransport(transports._FlowControlMixin,
elif
self
.
_closing
:
info
.
append
(
'closing'
)
info
.
append
(
'fd=%s'
%
self
.
_fileno
)
if
self
.
_pipe
is
not
None
:
selector
=
getattr
(
self
.
_loop
,
'_selector'
,
None
)
if
self
.
_pipe
is
not
None
and
selector
is
not
None
:
polling
=
selector_events
.
_test_selector_event
(
sel
f
.
_loop
.
_sel
ector
,
selector
,
self
.
_fileno
,
selectors
.
EVENT_WRITE
)
if
polling
:
info
.
append
(
'polling'
)
...
...
@@ -465,6 +469,8 @@ class _UnixWritePipeTransport(transports._FlowControlMixin,
bufsize
=
self
.
get_write_buffer_size
()
info
.
append
(
'bufsize=%s'
%
bufsize
)
elif
self
.
_pipe
is
not
None
:
info
.
append
(
'open'
)
else
:
info
.
append
(
'closed'
)
return
'<%s>'
%
' '
.
join
(
info
)
...
...
Lib/test/test_asyncio/test_events.py
View file @
2e413f7c
...
...
@@ -1366,6 +1366,41 @@ class EventLoopTestsMixin:
# extra info is available
self
.
assertIsNotNone
(
proto
.
transport
.
get_extra_info
(
'pipe'
))
@
unittest
.
skipUnless
(
sys
.
platform
!=
'win32'
,
"Don't support pipes for Windows"
)
def
test_unclosed_pipe_transport
(
self
):
# This test reproduces the issue #314 on GitHub
loop
=
self
.
create_event_loop
()
read_proto
=
MyReadPipeProto
(
loop
=
loop
)
write_proto
=
MyWritePipeProto
(
loop
=
loop
)
rpipe
,
wpipe
=
os
.
pipe
()
rpipeobj
=
io
.
open
(
rpipe
,
'rb'
,
1024
)
wpipeobj
=
io
.
open
(
wpipe
,
'w'
,
1024
)
@
asyncio
.
coroutine
def
connect
():
read_transport
,
_
=
yield
from
loop
.
connect_read_pipe
(
lambda
:
read_proto
,
rpipeobj
)
write_transport
,
_
=
yield
from
loop
.
connect_write_pipe
(
lambda
:
write_proto
,
wpipeobj
)
return
read_transport
,
write_transport
# Run and close the loop without closing the transports
read_transport
,
write_transport
=
loop
.
run_until_complete
(
connect
())
loop
.
close
()
# These 'repr' calls used to raise an AttributeError
# See Issue #314 on GitHub
self
.
assertIn
(
'open'
,
repr
(
read_transport
))
self
.
assertIn
(
'open'
,
repr
(
write_transport
))
# Clean up (avoid ResourceWarning)
rpipeobj
.
close
()
wpipeobj
.
close
()
read_transport
.
_pipe
=
None
write_transport
.
_pipe
=
None
@
unittest
.
skipUnless
(
sys
.
platform
!=
'win32'
,
"Don't support pipes for Windows"
)
# select, poll and kqueue don't support character devices (PTY) on Mac OS X
...
...
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