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
5746510b
Kaydet (Commit)
5746510b
authored
Şub 14, 2018
tarafından
Bar Harel
Kaydeden (comit)
Andrew Svetlov
Şub 14, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-32841: Fix cancellation in awaiting asyncio.Condition (#5665)
üst
3384d38d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
3 deletions
+32
-3
locks.py
Lib/asyncio/locks.py
+5
-1
test_locks.py
Lib/test/test_asyncio/test_locks.py
+25
-2
2018-02-14-00-21-24.bpo-32841.bvHDOc.rst
...S.d/next/Library/2018-02-14-00-21-24.bpo-32841.bvHDOc.rst
+2
-0
No files found.
Lib/asyncio/locks.py
Dosyayı görüntüle @
5746510b
...
@@ -358,12 +358,16 @@ class Condition(_ContextManagerMixin):
...
@@ -358,12 +358,16 @@ class Condition(_ContextManagerMixin):
finally
:
finally
:
# Must reacquire lock even if wait is cancelled
# Must reacquire lock even if wait is cancelled
cancelled
=
False
while
True
:
while
True
:
try
:
try
:
await
self
.
acquire
()
await
self
.
acquire
()
break
break
except
futures
.
CancelledError
:
except
futures
.
CancelledError
:
pass
cancelled
=
True
if
cancelled
:
raise
futures
.
CancelledError
async
def
wait_for
(
self
,
predicate
):
async
def
wait_for
(
self
,
predicate
):
"""Wait until a predicate becomes true.
"""Wait until a predicate becomes true.
...
...
Lib/test/test_asyncio/test_locks.py
Dosyayı görüntüle @
5746510b
...
@@ -248,8 +248,6 @@ class LockTests(test_utils.TestCase):
...
@@ -248,8 +248,6 @@ class LockTests(test_utils.TestCase):
test_utils
.
run_briefly
(
self
.
loop
)
test_utils
.
run_briefly
(
self
.
loop
)
self
.
assertTrue
(
t3
.
cancelled
())
self
.
assertTrue
(
t3
.
cancelled
())
def
test_finished_waiter_cancelled
(
self
):
def
test_finished_waiter_cancelled
(
self
):
lock
=
asyncio
.
Lock
(
loop
=
self
.
loop
)
lock
=
asyncio
.
Lock
(
loop
=
self
.
loop
)
...
@@ -576,6 +574,31 @@ class ConditionTests(test_utils.TestCase):
...
@@ -576,6 +574,31 @@ class ConditionTests(test_utils.TestCase):
self
.
assertTrue
(
cond
.
locked
())
self
.
assertTrue
(
cond
.
locked
())
def
test_wait_cancel_after_notify
(
self
):
# See bpo-32841
cond
=
asyncio
.
Condition
(
loop
=
self
.
loop
)
waited
=
False
async
def
wait_on_cond
():
nonlocal
waited
async
with
cond
:
waited
=
True
# Make sure this area was reached
await
cond
.
wait
()
waiter
=
asyncio
.
ensure_future
(
wait_on_cond
(),
loop
=
self
.
loop
)
test_utils
.
run_briefly
(
self
.
loop
)
# Start waiting
self
.
loop
.
run_until_complete
(
cond
.
acquire
())
cond
.
notify
()
test_utils
.
run_briefly
(
self
.
loop
)
# Get to acquire()
waiter
.
cancel
()
test_utils
.
run_briefly
(
self
.
loop
)
# Activate cancellation
cond
.
release
()
test_utils
.
run_briefly
(
self
.
loop
)
# Cancellation should occur
self
.
assertTrue
(
waiter
.
cancelled
())
self
.
assertTrue
(
waited
)
def
test_wait_unacquired
(
self
):
def
test_wait_unacquired
(
self
):
cond
=
asyncio
.
Condition
(
loop
=
self
.
loop
)
cond
=
asyncio
.
Condition
(
loop
=
self
.
loop
)
self
.
assertRaises
(
self
.
assertRaises
(
...
...
Misc/NEWS.d/next/Library/2018-02-14-00-21-24.bpo-32841.bvHDOc.rst
0 → 100644
Dosyayı görüntüle @
5746510b
Fixed `asyncio.Condition` issue which silently ignored cancellation after
notifying and cancelling a conditional lock. Patch by Bar Harel.
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