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
159fbdd8
Kaydet (Commit)
159fbdd8
authored
Agu 06, 2015
tarafından
Yury Selivanov
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #23812: Fix getter-cancellation with many pending getters code path
üst
86b34da5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
2 deletions
+37
-2
queues.py
Lib/asyncio/queues.py
+1
-1
test_queues.py
Lib/test/test_asyncio/test_queues.py
+36
-1
No files found.
Lib/asyncio/queues.py
Dosyayı görüntüle @
159fbdd8
...
...
@@ -228,7 +228,7 @@ class Queue:
'queue non-empty, why are getters waiting?'
)
getter
=
self
.
_getters
.
popleft
()
self
.
_put_internal
(
item
)
self
.
_
_
put_internal
(
item
)
# getter cannot be cancelled, we just removed done getters
getter
.
set_result
(
item
)
...
...
Lib/test/test_asyncio/test_queues.py
Dosyayı görüntüle @
159fbdd8
...
...
@@ -322,7 +322,7 @@ class QueuePutTests(_QueueTestBase):
q
.
put_nowait
(
1
)
self
.
assertEqual
(
1
,
q
.
get_nowait
())
def
test_get_cancel_drop
(
self
):
def
test_get_cancel_drop
_one_pending_reader
(
self
):
def
gen
():
yield
0.01
yield
0.1
...
...
@@ -350,6 +350,41 @@ class QueuePutTests(_QueueTestBase):
# if we get 2, it means 1 got dropped!
self
.
assertEqual
(
1
,
result
)
def
test_get_cancel_drop_many_pending_readers
(
self
):
def
gen
():
yield
0.01
yield
0.1
loop
=
self
.
new_test_loop
(
gen
)
loop
.
set_debug
(
True
)
q
=
asyncio
.
Queue
(
loop
=
loop
)
reader1
=
loop
.
create_task
(
q
.
get
())
reader2
=
loop
.
create_task
(
q
.
get
())
reader3
=
loop
.
create_task
(
q
.
get
())
loop
.
run_until_complete
(
asyncio
.
sleep
(
0.01
,
loop
=
loop
))
q
.
put_nowait
(
1
)
q
.
put_nowait
(
2
)
reader1
.
cancel
()
try
:
loop
.
run_until_complete
(
reader1
)
except
asyncio
.
CancelledError
:
pass
loop
.
run_until_complete
(
reader3
)
# reader2 will receive `2`, because it was added to the
# queue of pending readers *before* put_nowaits were called.
self
.
assertEqual
(
reader2
.
result
(),
2
)
# reader3 will receive `1`, because reader1 was cancelled
# before is had a chance to execute, and `2` was already
# pushed to reader2 by second `put_nowait`.
self
.
assertEqual
(
reader3
.
result
(),
1
)
def
test_put_cancel_drop
(
self
):
def
gen
():
...
...
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