Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
1cc0ee7d
Kaydet (Commit)
1cc0ee7d
authored
May 07, 2019
tarafından
Andrew Svetlov
Kaydeden (comit)
Miss Islington (bot)
May 07, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-36801: Fix waiting in StreamWriter.drain for closing SSL transport (GH-13098)
https://bugs.python.org/issue36801
üst
e19a91e4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
8 deletions
+46
-8
streams.py
Lib/asyncio/streams.py
+13
-8
subprocess.py
Lib/asyncio/subprocess.py
+9
-0
test_streams.py
Lib/test/test_asyncio/test_streams.py
+23
-0
2019-05-05-09-45-44.bpo-36801.XrlFFs.rst
...S.d/next/Library/2019-05-05-09-45-44.bpo-36801.XrlFFs.rst
+1
-0
No files found.
Lib/asyncio/streams.py
Dosyayı görüntüle @
1cc0ee7d
...
...
@@ -199,6 +199,9 @@ class FlowControlMixin(protocols.Protocol):
self
.
_drain_waiter
=
waiter
await
waiter
def
_get_close_waiter
(
self
,
stream
):
raise
NotImplementedError
class
StreamReaderProtocol
(
FlowControlMixin
,
protocols
.
Protocol
):
"""Helper class to adapt between Protocol and StreamReader.
...
...
@@ -315,6 +318,9 @@ class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):
return
False
return
True
def
_get_close_waiter
(
self
,
stream
):
return
self
.
_closed
def
__del__
(
self
):
# Prevent reports about unhandled exceptions.
# Better than self._closed._log_traceback = False hack
...
...
@@ -376,7 +382,7 @@ class StreamWriter:
return
self
.
_transport
.
is_closing
()
async
def
wait_closed
(
self
):
await
self
.
_protocol
.
_
closed
await
self
.
_protocol
.
_
get_close_waiter
(
self
)
def
get_extra_info
(
self
,
name
,
default
=
None
):
return
self
.
_transport
.
get_extra_info
(
name
,
default
)
...
...
@@ -394,13 +400,12 @@ class StreamWriter:
if
exc
is
not
None
:
raise
exc
if
self
.
_transport
.
is_closing
():
# Yield to the event loop so connection_lost() may be
# called. Without this, _drain_helper() would return
# immediately, and code that calls
# write(...); await drain()
# in a loop would never call connection_lost(), so it
# would not see an error when the socket is closed.
await
sleep
(
0
,
loop
=
self
.
_loop
)
# Wait for protocol.connection_lost() call
# Raise connection closing error if any,
# ConnectionResetError otherwise
fut
=
self
.
_protocol
.
_get_close_waiter
(
self
)
await
fut
raise
ConnectionResetError
(
'Connection lost'
)
await
self
.
_protocol
.
_drain_helper
()
async
def
aclose
(
self
):
...
...
Lib/asyncio/subprocess.py
Dosyayı görüntüle @
1cc0ee7d
...
...
@@ -26,6 +26,7 @@ class SubprocessStreamProtocol(streams.FlowControlMixin,
self
.
_transport
=
None
self
.
_process_exited
=
False
self
.
_pipe_fds
=
[]
self
.
_stdin_closed
=
self
.
_loop
.
create_future
()
def
__repr__
(
self
):
info
=
[
self
.
__class__
.
__name__
]
...
...
@@ -80,6 +81,10 @@ class SubprocessStreamProtocol(streams.FlowControlMixin,
if
pipe
is
not
None
:
pipe
.
close
()
self
.
connection_lost
(
exc
)
if
exc
is
None
:
self
.
_stdin_closed
.
set_result
(
None
)
else
:
self
.
_stdin_closed
.
set_exception
(
exc
)
return
if
fd
==
1
:
reader
=
self
.
stdout
...
...
@@ -106,6 +111,10 @@ class SubprocessStreamProtocol(streams.FlowControlMixin,
self
.
_transport
.
close
()
self
.
_transport
=
None
def
_get_close_waiter
(
self
,
stream
):
if
stream
is
self
.
stdin
:
return
self
.
_stdin_closed
class
Process
:
def
__init__
(
self
,
transport
,
protocol
,
loop
,
*
,
_asyncio_internal
=
False
):
...
...
Lib/test/test_asyncio/test_streams.py
Dosyayı görüntüle @
1cc0ee7d
...
...
@@ -109,6 +109,29 @@ class StreamTests(test_utils.TestCase):
self
.
_basetest_open_connection_no_loop_ssl
(
conn_fut
)
@unittest.skipIf
(
ssl
is
None
,
'No ssl module'
)
def
test_drain_on_closed_writer_ssl
(
self
):
async
def
inner
(
httpd
):
reader
,
writer
=
await
asyncio
.
open_connection
(
*
httpd
.
address
,
ssl
=
test_utils
.
dummy_ssl_context
())
messages
=
[]
self
.
loop
.
set_exception_handler
(
lambda
loop
,
ctx
:
messages
.
append
(
ctx
))
writer
.
write
(
b
'GET / HTTP/1.0
\r\n\r\n
'
)
data
=
await
reader
.
read
()
self
.
assertTrue
(
data
.
endswith
(
b
'
\r\n\r\n
Test message'
))
writer
.
close
()
with
self
.
assertRaises
(
ConnectionResetError
):
await
writer
.
drain
()
self
.
assertEqual
(
messages
,
[])
with
test_utils
.
run_test_server
(
use_ssl
=
True
)
as
httpd
:
self
.
loop
.
run_until_complete
(
inner
(
httpd
))
def
_basetest_open_connection_error
(
self
,
open_connection_fut
):
messages
=
[]
self
.
loop
.
set_exception_handler
(
lambda
loop
,
ctx
:
messages
.
append
(
ctx
))
...
...
Misc/NEWS.d/next/Library/2019-05-05-09-45-44.bpo-36801.XrlFFs.rst
0 → 100644
Dosyayı görüntüle @
1cc0ee7d
Properly handle SSL connection closing in asyncio StreamWriter.drain() call.
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