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
7709b4d5
Kaydet (Commit)
7709b4d5
authored
Haz 23, 2017
tarafından
Serhiy Storchaka
Kaydeden (comit)
GitHub
Haz 23, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
[2.7] bpo-30727: Fix a race condition in test_threading. (GH-2334). (#2353)
(cherry picked from commit
32cb968a
)
üst
50826743
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
lock_tests.py
Lib/test/lock_tests.py
+14
-5
No files found.
Lib/test/lock_tests.py
Dosyayı görüntüle @
7709b4d5
...
...
@@ -359,21 +359,28 @@ class ConditionTests(BaseTestCase):
# construct. In particular, it is possible that this can no longer
# be conveniently guaranteed should their implementation ever change.
N
=
5
ready
=
[]
results1
=
[]
results2
=
[]
phase_num
=
0
def
f
():
cond
.
acquire
()
ready
.
append
(
phase_num
)
cond
.
wait
()
cond
.
release
()
results1
.
append
(
phase_num
)
cond
.
acquire
()
ready
.
append
(
phase_num
)
cond
.
wait
()
cond
.
release
()
results2
.
append
(
phase_num
)
b
=
Bunch
(
f
,
N
)
b
.
wait_for_started
()
_wait
()
# first wait, to ensure all workers settle into cond.wait() before
# we continue. See issues #8799 and #30727.
while
len
(
ready
)
<
5
:
_wait
()
ready
=
[]
self
.
assertEqual
(
results1
,
[])
# Notify 3 threads at first
cond
.
acquire
()
...
...
@@ -385,9 +392,9 @@ class ConditionTests(BaseTestCase):
_wait
()
self
.
assertEqual
(
results1
,
[
1
]
*
3
)
self
.
assertEqual
(
results2
,
[])
#
first wait, to ensure all workers settle into cond.wait() before
# we continue. See issue #8799
_wait
()
#
make sure all awaken workers settle into cond.wait()
while
len
(
ready
)
<
3
:
_wait
()
# Notify 5 threads: they might be in their first or second wait
cond
.
acquire
()
cond
.
notify
(
5
)
...
...
@@ -398,7 +405,9 @@ class ConditionTests(BaseTestCase):
_wait
()
self
.
assertEqual
(
results1
,
[
1
]
*
3
+
[
2
]
*
2
)
self
.
assertEqual
(
results2
,
[
2
]
*
3
)
_wait
()
# make sure all workers settle into cond.wait()
# make sure all workers settle into cond.wait()
while
len
(
ready
)
<
5
:
_wait
()
# Notify all threads: they are all in their second wait
cond
.
acquire
()
cond
.
notify_all
()
...
...
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