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
9c55a58a
Kaydet (Commit)
9c55a58a
authored
Kas 21, 2013
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
asyncio: Make Semaphore(0) work properly.
üst
d88c6f9b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
2 deletions
+6
-2
locks.py
Lib/asyncio/locks.py
+2
-2
test_locks.py
Lib/test/test_asyncio/test_locks.py
+4
-0
No files found.
Lib/asyncio/locks.py
Dosyayı görüntüle @
9c55a58a
...
...
@@ -348,12 +348,12 @@ class Semaphore:
def
__init__
(
self
,
value
=
1
,
bound
=
False
,
*
,
loop
=
None
):
if
value
<
0
:
raise
ValueError
(
"Semaphore initial value must be > 0"
)
raise
ValueError
(
"Semaphore initial value must be >
=
0"
)
self
.
_value
=
value
self
.
_bound
=
bound
self
.
_bound_value
=
value
self
.
_waiters
=
collections
.
deque
()
self
.
_locked
=
False
self
.
_locked
=
(
value
==
0
)
if
loop
is
not
None
:
self
.
_loop
=
loop
else
:
...
...
Lib/test/test_asyncio/test_locks.py
Dosyayı görüntüle @
9c55a58a
...
...
@@ -684,6 +684,10 @@ class SemaphoreTests(unittest.TestCase):
finally
:
events
.
set_event_loop
(
None
)
def
test_initial_value_zero
(
self
):
sem
=
locks
.
Semaphore
(
0
,
loop
=
self
.
loop
)
self
.
assertTrue
(
sem
.
locked
())
def
test_repr
(
self
):
sem
=
locks
.
Semaphore
(
loop
=
self
.
loop
)
self
.
assertTrue
(
repr
(
sem
)
.
endswith
(
'[unlocked,value:1]>'
))
...
...
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