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
d35bf032
Kaydet (Commit)
d35bf032
authored
Haz 11, 2016
tarafından
Yury Selivanov
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge 3.5 (issue #22970)
üst
6588712b
c92bf83a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
1 deletion
+32
-1
locks.py
Lib/asyncio/locks.py
+7
-1
test_locks.py
Lib/test/test_asyncio/test_locks.py
+25
-0
No files found.
Lib/asyncio/locks.py
Dosyayı görüntüle @
d35bf032
...
@@ -329,7 +329,13 @@ class Condition(_ContextManagerMixin):
...
@@ -329,7 +329,13 @@ class Condition(_ContextManagerMixin):
self
.
_waiters
.
remove
(
fut
)
self
.
_waiters
.
remove
(
fut
)
finally
:
finally
:
yield
from
self
.
acquire
()
# Must reacquire lock even if wait is cancelled
while
True
:
try
:
yield
from
self
.
acquire
()
break
except
futures
.
CancelledError
:
pass
@coroutine
@coroutine
def
wait_for
(
self
,
predicate
):
def
wait_for
(
self
,
predicate
):
...
...
Lib/test/test_asyncio/test_locks.py
Dosyayı görüntüle @
d35bf032
...
@@ -457,6 +457,31 @@ class ConditionTests(test_utils.TestCase):
...
@@ -457,6 +457,31 @@ class ConditionTests(test_utils.TestCase):
self
.
assertFalse
(
cond
.
_waiters
)
self
.
assertFalse
(
cond
.
_waiters
)
self
.
assertTrue
(
cond
.
locked
())
self
.
assertTrue
(
cond
.
locked
())
def
test_wait_cancel_contested
(
self
):
cond
=
asyncio
.
Condition
(
loop
=
self
.
loop
)
self
.
loop
.
run_until_complete
(
cond
.
acquire
())
self
.
assertTrue
(
cond
.
locked
())
wait_task
=
asyncio
.
Task
(
cond
.
wait
(),
loop
=
self
.
loop
)
test_utils
.
run_briefly
(
self
.
loop
)
self
.
assertFalse
(
cond
.
locked
())
# Notify, but contest the lock before cancelling
self
.
loop
.
run_until_complete
(
cond
.
acquire
())
self
.
assertTrue
(
cond
.
locked
())
cond
.
notify
()
self
.
loop
.
call_soon
(
wait_task
.
cancel
)
self
.
loop
.
call_soon
(
cond
.
release
)
try
:
self
.
loop
.
run_until_complete
(
wait_task
)
except
asyncio
.
CancelledError
:
# Should not happen, since no cancellation points
pass
self
.
assertTrue
(
cond
.
locked
())
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
(
...
...
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