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
fef7098e
Kaydet (Commit)
fef7098e
authored
Ock 26, 2014
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
asyncio: Rename {Empty,Full} to {QueueEmpty,QueueFull} and no longer get them from queue.py.
üst
ab3c8898
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
11 deletions
+21
-11
queues.py
Lib/asyncio/queues.py
+19
-9
test_queues.py
Lib/test/test_asyncio/test_queues.py
+2
-2
No files found.
Lib/asyncio/queues.py
Dosyayı görüntüle @
fef7098e
"""Queues"""
__all__
=
[
'Queue'
,
'PriorityQueue'
,
'LifoQueue'
,
'JoinableQueue'
,
'
Full'
,
'
Empty'
]
'
QueueFull'
,
'Queue
Empty'
]
import
collections
import
heapq
import
queue
from
.
import
events
from
.
import
futures
...
...
@@ -13,9 +12,20 @@ from . import locks
from
.tasks
import
coroutine
# Re-export queue.Full and .Empty exceptions.
Full
=
queue
.
Full
Empty
=
queue
.
Empty
class
QueueEmpty
(
Exception
):
'Exception raised by Queue.get(block=0)/get_nowait().'
pass
class
QueueFull
(
Exception
):
'Exception raised by Queue.put(block=0)/put_nowait().'
pass
# Un-exported aliases for temporary backward compatibility.
# Will disappear soon.
Full
=
QueueFull
Empty
=
QueueEmpty
class
Queue
:
...
...
@@ -134,7 +144,7 @@ class Queue:
def
put_nowait
(
self
,
item
):
"""Put an item into the queue without blocking.
If no free slot is immediately available, raise Full.
If no free slot is immediately available, raise
Queue
Full.
"""
self
.
_consume_done_getters
()
if
self
.
_getters
:
...
...
@@ -149,7 +159,7 @@ class Queue:
getter
.
set_result
(
self
.
_get
())
elif
self
.
_maxsize
>
0
and
self
.
_maxsize
==
self
.
qsize
():
raise
Full
raise
Queue
Full
else
:
self
.
_put
(
item
)
...
...
@@ -184,7 +194,7 @@ class Queue:
def
get_nowait
(
self
):
"""Remove and return an item from the queue.
Return an item if one is immediately available, else raise Empty.
Return an item if one is immediately available, else raise
Queue
Empty.
"""
self
.
_consume_done_putters
()
if
self
.
_putters
:
...
...
@@ -199,7 +209,7 @@ class Queue:
elif
self
.
qsize
():
return
self
.
_get
()
else
:
raise
Empty
raise
Queue
Empty
class
PriorityQueue
(
Queue
):
...
...
Lib/test/test_asyncio/test_queues.py
Dosyayı görüntüle @
fef7098e
...
...
@@ -230,7 +230,7 @@ class QueueGetTests(_QueueTestBase):
def
test_nonblocking_get_exception
(
self
):
q
=
asyncio
.
Queue
(
loop
=
self
.
loop
)
self
.
assertRaises
(
asyncio
.
Empty
,
q
.
get_nowait
)
self
.
assertRaises
(
asyncio
.
Queue
Empty
,
q
.
get_nowait
)
def
test_get_cancelled
(
self
):
...
...
@@ -337,7 +337,7 @@ class QueuePutTests(_QueueTestBase):
def
test_nonblocking_put_exception
(
self
):
q
=
asyncio
.
Queue
(
maxsize
=
1
,
loop
=
self
.
loop
)
q
.
put_nowait
(
1
)
self
.
assertRaises
(
asyncio
.
Full
,
q
.
put_nowait
,
2
)
self
.
assertRaises
(
asyncio
.
Queue
Full
,
q
.
put_nowait
,
2
)
def
test_put_cancelled
(
self
):
q
=
asyncio
.
Queue
(
loop
=
self
.
loop
)
...
...
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