Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

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

wants to merge 1 commit into from

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Jul 9, 2019

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
Copy link
Member Author

vstinner commented Jul 9, 2019

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
Copy link
Contributor

@aeros aeros left a comment

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
Copy link
Member Author

vstinner commented Jul 9, 2019

@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
Copy link
Contributor

aeros commented Jul 9, 2019

@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