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
7634e1cf
Kaydet (Commit)
7634e1cf
authored
Eki 09, 2013
tarafından
Tim Peters
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue 19158: a rare race in BoundedSemaphore could allow .release() too often.
üst
ee82d0b2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
3 deletions
+23
-3
test_threading.py
Lib/test/test_threading.py
+18
-0
threading.py
Lib/threading.py
+5
-3
No files found.
Lib/test/test_threading.py
Dosyayı görüntüle @
7634e1cf
...
...
@@ -468,6 +468,24 @@ class ThreadTests(BaseTestCase):
self
.
assertEqual
(
0
,
status
)
def
test_BoundedSemaphore_limit
(
self
):
# BoundedSemaphore should raise ValueError if released too often.
for
limit
in
range
(
1
,
10
):
bs
=
threading
.
BoundedSemaphore
(
limit
)
threads
=
[
threading
.
Thread
(
target
=
bs
.
acquire
)
for
_
in
range
(
limit
)]
for
t
in
threads
:
t
.
start
()
for
t
in
threads
:
t
.
join
()
threads
=
[
threading
.
Thread
(
target
=
bs
.
release
)
for
_
in
range
(
limit
)]
for
t
in
threads
:
t
.
start
()
for
t
in
threads
:
t
.
join
()
self
.
assertRaises
(
ValueError
,
bs
.
release
)
class
ThreadJoinOnShutdown
(
BaseTestCase
):
# Between fork() and exec(), only async-safe functions are allowed (issues
...
...
Lib/threading.py
Dosyayı görüntüle @
7634e1cf
...
...
@@ -283,9 +283,11 @@ class BoundedSemaphore(Semaphore):
self
.
_initial_value
=
value
def
release
(
self
):
if
self
.
_value
>=
self
.
_initial_value
:
raise
ValueError
(
"Semaphore released too many times"
)
return
Semaphore
.
release
(
self
)
with
self
.
_cond
:
if
self
.
_value
>=
self
.
_initial_value
:
raise
ValueError
(
"Semaphore released too many times"
)
self
.
_value
+=
1
self
.
_cond
.
notify
()
class
Event
:
...
...
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