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
a39eb0f4
Kaydet (Commit)
a39eb0f4
authored
Ock 15, 2015
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge 3.4 (asyncio)
üst
9fef5244
922bc2ca
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
4 deletions
+35
-4
tasks.py
Lib/asyncio/tasks.py
+8
-4
test_tasks.py
Lib/test/test_asyncio/test_tasks.py
+27
-0
No files found.
Lib/asyncio/tasks.py
Dosyayı görüntüle @
a39eb0f4
...
...
@@ -347,10 +347,9 @@ def wait_for(fut, timeout, *, loop=None):
it cancels the task and raises TimeoutError. To avoid the task
cancellation, wrap it in shield().
Usage:
result = yield from asyncio.wait_for(fut, 10.0)
If the wait is cancelled, the task is also cancelled.
This function is a coroutine.
"""
if
loop
is
None
:
loop
=
events
.
get_event_loop
()
...
...
@@ -367,7 +366,12 @@ def wait_for(fut, timeout, *, loop=None):
try
:
# wait until the future completes or the timeout
yield
from
waiter
try
:
yield
from
waiter
except
futures
.
CancelledError
:
fut
.
remove_done_callback
(
cb
)
fut
.
cancel
()
raise
if
fut
.
done
():
return
fut
.
result
()
...
...
Lib/test/test_asyncio/test_tasks.py
Dosyayı görüntüle @
a39eb0f4
...
...
@@ -1705,6 +1705,33 @@ class TaskTests(test_utils.TestCase):
'test_task_source_traceback'
))
self
.
loop
.
run_until_complete
(
task
)
def
_test_cancel_wait_for
(
self
,
timeout
):
loop
=
asyncio
.
new_event_loop
()
self
.
addCleanup
(
loop
.
close
)
@asyncio.coroutine
def
blocking_coroutine
():
fut
=
asyncio
.
Future
(
loop
=
loop
)
# Block: fut result is never set
yield
from
fut
task
=
loop
.
create_task
(
blocking_coroutine
())
wait
=
loop
.
create_task
(
asyncio
.
wait_for
(
task
,
timeout
,
loop
=
loop
))
loop
.
call_soon
(
wait
.
cancel
)
self
.
assertRaises
(
asyncio
.
CancelledError
,
loop
.
run_until_complete
,
wait
)
# Python issue #23219: cancelling the wait must also cancel the task
self
.
assertTrue
(
task
.
cancelled
())
def
test_cancel_blocking_wait_for
(
self
):
self
.
_test_cancel_wait_for
(
None
)
def
test_cancel_wait_for
(
self
):
self
.
_test_cancel_wait_for
(
60.0
)
class
GatherTestsBase
:
...
...
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