Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

bpo-37322: Fix again test_ssl.test_pha_required_nocert() ResourceWarning#14667

Closed
vstinner wants to merge 1 commit into
python:masterpython/cpython:masterfrom
vstinner:test_pha_required_nocert_reswarn2Copy head branch name to clipboard
Closed

bpo-37322: Fix again test_ssl.test_pha_required_nocert() ResourceWarning#14667
vstinner wants to merge 1 commit into
python:masterpython/cpython:masterfrom
vstinner:test_pha_required_nocert_reswarn2Copy head branch name to clipboard

Conversation

@vstinner

@vstinner vstinner commented Jul 9, 2019

Copy link
Copy Markdown
Member

test_ssl.test_pha_required_nocert(): only close the TLS connection at
the server side once the handler completed.

https://bugs.python.org/issue37322

test_ssl.test_pha_required_nocert(): only close the TLS connection at
the server side once the handler completed.
@vstinner

vstinner commented Jul 9, 2019

Copy link
Copy Markdown
Member Author

It seems like the test fails sometimes on Windows. I don't have time right now to investigate, so I will just revert my change instead, PR #14662.

@vstinner vstinner closed this Jul 9, 2019
@vstinner vstinner deleted the test_pha_required_nocert_reswarn2 branch July 9, 2019 11:18

@aeros aeros left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps instead of explicitly using handler.close(), you could use a with statement to guarantee that the resource is safely closed:

with self.ConnectionHandler(self, newconn, connaddr) as handler:
    handler.start()
    handler.join()

This only requires that the object has an __enter__ and __exit__ method, which ConnectionHandler does.

Also as a minor readability change, I would recommend changing this (lines 2457 & 2458):

sys.stdout.write(' server:  new connection from ' 
    + repr(connaddr) + '\n')

to:

sys.stdout.write(f"server:  new connection from {conaddr!r}\n")

This isn't at all necessary, but I figured since it was right near by it would be a good time it clean it up a little. I find the f string formatting a lot easier to quickly read than the old string concatenation.

@vstinner

vstinner commented Jul 9, 2019

Copy link
Copy Markdown
Member Author

@aeros167: You are commenting a closed PR :-) I abandoned it since the test was still failing randomly with this change when combined with commit 73ea546.

@aeros

aeros commented Jul 9, 2019

Copy link
Copy Markdown
Contributor

@vstinner Oops, I started typing it while it was still open, my apologies (started typing the review a bit ago and got distracted). Do you think this would be worth reopening the issue over to test if my suggestion fixes the ResourceWarning and issue with windows compatibility? I wouldn't mind opening a draft PR and just to experiment with it if you're otherwise occupied.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.