Skip to content

bpo-32574: asyncio.Queue, put() leaks memory#5208

Merged
1st1 merged 4 commits into
python:masterfrom
jmf-mordis:fix-issue-32574
Jan 25, 2018
Merged

bpo-32574: asyncio.Queue, put() leaks memory#5208
1st1 merged 4 commits into
python:masterfrom
jmf-mordis:fix-issue-32574

Conversation

@jmf-mordis

@jmf-mordis jmf-mordis commented Jan 16, 2018

Copy link
Copy Markdown
Contributor

@the-knights-who-say-ni

Copy link
Copy Markdown

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately our records indicate you have not signed the CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

Thanks again to your contribution and we look forward to looking at it!

@jmf-mordis

jmf-mordis commented Jan 16, 2018

Copy link
Copy Markdown
Contributor Author

I sign the CLA some minutes ago, I am waiting for the verification.

Comment thread Lib/asyncio/queues.py
try:
self._putters.remove(putter)
except ValueError:
pass

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I applied this patch and changed pass to raise. Nothing happened, test_cancelled_putters_not_being_held_in_self_putters passed just fine. Putting a print() before raise showed that this except block isn't triggered by the test at all.

All in all, I don't understand this fix. Please make sure that the test (a) triggers the code you change; (b) there's a clear comment in the code explaining why/what it's doing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a refactor of the test with the proper comments, comments to the bugfix explaining it, and added also another test to ensure that the except block is correctly executed.

The requested changes are really similar to the merged code of the following link, it is the same memory leak but in the getters instead of the putters.

c62f0cb#diff-3947468b604f664993c24d2b5560635c

I think that now the code is much more clear and easy to understand, thx for the correction.

@bedevere-bot

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

- Added comments explaining the problem to the test and the bugfix.
- Added one test to ensure that the ValueError is silenced.
- Refactor of the other test.
@jmf-mordis

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again

@bedevere-bot

Copy link
Copy Markdown

Thanks for making the requested changes!

@asvetlov, @1st1: please review the changes made to this pull request.

@asvetlov

Copy link
Copy Markdown
Contributor

Looks like now all code paths are covered by unit tests.
@1st1 please review again.

Comment thread Lib/asyncio/queues.py Outdated
# Clean self._putters from canceled putters.
self._putters.remove(putter)
except ValueError:
# The putter could be removed from self._putters by a previous get_nowait call.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is longer than 79 characters, right? Please PEP8 the code.

@1st1 1st1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks OK, but please fix the code style—PEP8.

@bedevere-bot

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@jmf-mordis

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again. Ups, I had the entire work environment with the right margin at 120, sorry, fixed code style.

@bedevere-bot

Copy link
Copy Markdown

Thanks for making the requested changes!

@1st1, @asvetlov: please review the changes made to this pull request.

@1st1

1st1 commented Jan 25, 2018

Copy link
Copy Markdown
Member

Thank you, José!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants