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
c62f0cb3
Commit
c62f0cb3
authored
Nov 07, 2017
by
Suren Nihalani
Committed by
Andrew Svetlov
Nov 07, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-31620: have asyncio/queues not leak memory when you've exceptions during waiting (#3813)
parent
c060c7e3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
0 deletions
+25
-0
Lib/asyncio/queues.py
Lib/asyncio/queues.py
+6
-0
Lib/test/test_asyncio/test_queues.py
Lib/test/test_asyncio/test_queues.py
+17
-0
Misc/NEWS.d/next/Library/2017-10-06-04-35-31.bpo-31620.gksLA1.rst
...S.d/next/Library/2017-10-06-04-35-31.bpo-31620.gksLA1.rst
+2
-0
No files found.
Lib/asyncio/queues.py
View file @
c62f0cb3
...
@@ -167,6 +167,12 @@ class Queue:
...
@@ -167,6 +167,12 @@ class Queue:
yield
from
getter
yield
from
getter
except
:
except
:
getter
.
cancel
()
# Just in case getter is not done yet.
getter
.
cancel
()
# Just in case getter is not done yet.
try
:
self
.
_getters
.
remove
(
getter
)
except
ValueError
:
pass
if
not
self
.
empty
()
and
not
getter
.
cancelled
():
if
not
self
.
empty
()
and
not
getter
.
cancelled
():
# We were woken up by put_nowait(), but can't take
# We were woken up by put_nowait(), but can't take
# the call. Wake up the next in line.
# the call. Wake up the next in line.
...
...
Lib/test/test_asyncio/test_queues.py
View file @
c62f0cb3
...
@@ -295,6 +295,23 @@ class QueueGetTests(_QueueTestBase):
...
@@ -295,6 +295,23 @@ class QueueGetTests(_QueueTestBase):
loop
=
self
.
loop
),
loop
=
self
.
loop
),
)
)
def
test_cancelled_getters_not_being_held_in_self_getters
(
self
):
def
a_generator
():
yield
0.1
yield
0.2
self
.
loop
=
self
.
new_test_loop
(
a_generator
)
@
asyncio
.
coroutine
def
consumer
(
queue
):
try
:
item
=
yield
from
asyncio
.
wait_for
(
queue
.
get
(),
0.1
,
loop
=
self
.
loop
)
except
asyncio
.
TimeoutError
:
pass
queue
=
asyncio
.
Queue
(
loop
=
self
.
loop
,
maxsize
=
5
)
self
.
loop
.
run_until_complete
(
self
.
loop
.
create_task
(
consumer
(
queue
)))
self
.
assertEqual
(
len
(
queue
.
_getters
),
0
)
class
QueuePutTests
(
_QueueTestBase
):
class
QueuePutTests
(
_QueueTestBase
):
...
...
Misc/NEWS.d/next/Library/2017-10-06-04-35-31.bpo-31620.gksLA1.rst
0 → 100644
View file @
c62f0cb3
an empty asyncio.Queue now doesn't leak memory when queue.get pollers
timeout
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