Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
66dc6b0f
Commit
66dc6b0f
authored
Jun 17, 2014
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #21723: asyncio.Queue: support any type of number (ex: float) for the
maximum size. Patch written by Vajrasky Kok.
parent
14fbe727
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
3 deletions
+21
-3
Lib/asyncio/queues.py
Lib/asyncio/queues.py
+3
-3
Lib/test/test_asyncio/test_queues.py
Lib/test/test_asyncio/test_queues.py
+15
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/asyncio/queues.py
View file @
66dc6b0f
...
...
@@ -105,7 +105,7 @@ class Queue:
if
self
.
_maxsize
<=
0
:
return
False
else
:
return
self
.
qsize
()
=
=
self
.
_maxsize
return
self
.
qsize
()
>
=
self
.
_maxsize
@
coroutine
def
put
(
self
,
item
):
...
...
@@ -126,7 +126,7 @@ class Queue:
self
.
_put
(
item
)
getter
.
set_result
(
self
.
_get
())
elif
self
.
_maxsize
>
0
and
self
.
_maxsize
=
=
self
.
qsize
():
elif
self
.
_maxsize
>
0
and
self
.
_maxsize
<
=
self
.
qsize
():
waiter
=
futures
.
Future
(
loop
=
self
.
_loop
)
self
.
_putters
.
append
((
item
,
waiter
))
...
...
@@ -152,7 +152,7 @@ class Queue:
self
.
_put
(
item
)
getter
.
set_result
(
self
.
_get
())
elif
self
.
_maxsize
>
0
and
self
.
_maxsize
=
=
self
.
qsize
():
elif
self
.
_maxsize
>
0
and
self
.
_maxsize
<
=
self
.
qsize
():
raise
QueueFull
else
:
self
.
_put
(
item
)
...
...
Lib/test/test_asyncio/test_queues.py
View file @
66dc6b0f
...
...
@@ -339,6 +339,21 @@ class QueuePutTests(_QueueTestBase):
q
.
put_nowait
(
1
)
self
.
assertRaises
(
asyncio
.
QueueFull
,
q
.
put_nowait
,
2
)
def
test_float_maxsize
(
self
):
q
=
asyncio
.
Queue
(
maxsize
=
1.3
,
loop
=
self
.
loop
)
q
.
put_nowait
(
1
)
q
.
put_nowait
(
2
)
self
.
assertTrue
(
q
.
full
())
self
.
assertRaises
(
asyncio
.
QueueFull
,
q
.
put_nowait
,
3
)
q
=
asyncio
.
Queue
(
maxsize
=
1.3
,
loop
=
self
.
loop
)
@
asyncio
.
coroutine
def
queue_put
():
yield
from
q
.
put
(
1
)
yield
from
q
.
put
(
2
)
self
.
assertTrue
(
q
.
full
())
self
.
loop
.
run_until_complete
(
queue_put
())
def
test_put_cancelled
(
self
):
q
=
asyncio
.
Queue
(
loop
=
self
.
loop
)
...
...
Misc/NEWS
View file @
66dc6b0f
...
...
@@ -27,6 +27,9 @@ Core and Builtins
Library
-------
- Issue #21723: asyncio.Queue: support any type of number (ex: float) for the
maximum size. Patch written by Vajrasky Kok.
- Issue #21326: Add a new is_closed() method to asyncio.BaseEventLoop.
run_forever() and run_until_complete() methods of asyncio.BaseEventLoop now
raise an exception if the event loop was closed.
...
...
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