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
c44ecdf6
Kaydet (Commit)
c44ecdf6
authored
Eki 19, 2015
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #25441: asyncio: Raise error from drain() when socket is closed.
üst
2bf91bf4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
0 deletions
+54
-0
streams.py
Lib/asyncio/streams.py
+9
-0
test_streams.py
Lib/test/test_asyncio/test_streams.py
+43
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/asyncio/streams.py
Dosyayı görüntüle @
c44ecdf6
...
...
@@ -301,6 +301,15 @@ class StreamWriter:
exc
=
self
.
_reader
.
exception
()
if
exc
is
not
None
:
raise
exc
if
self
.
_transport
is
not
None
:
if
self
.
_transport
.
_closing
:
# Yield to the event loop so connection_lost() may be
# called. Without this, _drain_helper() would return
# immediately, and code that calls
# write(...); yield from drain()
# in a loop would never call connection_lost(), so it
# would not see an error when the socket is closed.
yield
yield
from
self
.
_protocol
.
_drain_helper
()
...
...
Lib/test/test_asyncio/test_streams.py
Dosyayı görüntüle @
c44ecdf6
...
...
@@ -2,8 +2,10 @@
import
gc
import
os
import
queue
import
socket
import
sys
import
threading
import
unittest
from
unittest
import
mock
try
:
...
...
@@ -632,6 +634,47 @@ os.close(fd)
protocol
=
asyncio
.
StreamReaderProtocol
(
reader
)
self
.
assertIs
(
protocol
.
_loop
,
self
.
loop
)
def
test_drain_raises
(
self
):
# See http://bugs.python.org/issue25441
# This test should not use asyncio for the mock server; the
# whole point of the test is to test for a bug in drain()
# where it never gives up the event loop but the socket is
# closed on the server side.
q
=
queue
.
Queue
()
def
server
():
# Runs in a separate thread.
sock
=
socket
.
socket
()
sock
.
bind
((
'localhost'
,
0
))
sock
.
listen
(
1
)
addr
=
sock
.
getsockname
()
q
.
put
(
addr
)
clt
,
_
=
sock
.
accept
()
clt
.
close
()
@asyncio.coroutine
def
client
(
host
,
port
):
reader
,
writer
=
yield
from
asyncio
.
open_connection
(
host
,
port
,
loop
=
self
.
loop
)
while
True
:
writer
.
write
(
b
"foo
\n
"
)
yield
from
writer
.
drain
()
# Start the server thread and wait for it to be listening.
thread
=
threading
.
Thread
(
target
=
server
)
thread
.
setDaemon
(
True
)
thread
.
start
()
addr
=
q
.
get
()
# Should not be stuck in an infinite loop.
with
self
.
assertRaises
((
ConnectionResetError
,
BrokenPipeError
)):
self
.
loop
.
run_until_complete
(
client
(
*
addr
))
# Clean up the thread. (Only on success; on failure, it may
# be stuck in accept().)
thread
.
join
()
def
test___repr__
(
self
):
stream
=
asyncio
.
StreamReader
(
loop
=
self
.
loop
)
self
.
assertEqual
(
"<StreamReader>"
,
repr
(
stream
))
...
...
Misc/NEWS
Dosyayı görüntüle @
c44ecdf6
...
...
@@ -96,6 +96,8 @@ Core and Builtins
Library
-------
- Issue #25441: asyncio: Raise error from drain() when socket is closed.
- Issue #25411: Improved Unicode support in SMTPHandler through better use of
the email package. Thanks to user simon04 for the patch.
...
...
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