Skip to content

gh-69282: test_httpservers hangs since Python 3.5 #9564

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

WildCard65
Copy link
Contributor

@WildCard65 WildCard65 commented Sep 25, 2018

Added the following headers to RequestHandlerLoggingTestCase.test_get HTTP client request: Connection (value; close), Content-Length (value: 0)

This is a remake of the PR due to screw up I made in the last one.

https://bugs.python.org/issue25095

@matrixise
Copy link
Member

@vadmium what do you think about this PR?

@csabella csabella requested review from vadmium and removed request for vadmium February 4, 2020 01:24
@csabella
Copy link
Contributor

@WildCard65, please address the comments that @vadmium left on the bug tracker for this. Thank you!

Added 'self.con.close()' after 'self.con.getresponse()' to close the socket connection.
Kept the 'Connection' header in the request to signal our intent to terminate the socket.
@WildCard65
Copy link
Contributor Author

@csabella I made the requested changes.

@hugovk
Copy link
Member

hugovk commented Jan 6, 2022

This is ready for review.

@ambv ambv removed the needs backport to 3.9 only security fixes label May 17, 2022
@ambv
Copy link
Contributor

ambv commented May 17, 2022

This missed the boat for inclusion in Python 3.9 which accepts security fixes only as of today.

@hauntsaninja hauntsaninja changed the title bpo-25095: test_httpservers hangs since Python 3.5 gh-69282: test_httpservers hangs since Python 3.5 Feb 9, 2023
@arhadthedev
Copy link
Member

#69282 (comment)

@hugovk hugovk removed the needs backport to 3.10 only security fixes label Apr 6, 2023
@AA-Turner AA-Turner added the needs backport to 3.12 only security fixes label Aug 13, 2023
Copy link
Member

@AA-Turner AA-Turner left a comment

Choose a reason for hiding this comment

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

This patch seems fine and addresses all the points raised in #69282.

A

@terryjreedy
Copy link
Member

This issue and PR are no longer needed in that test_httpservers runs fine since 3.9. If some coredev familiar enough with httpserver thinks that the changes are a good idea anyway, please merge.

@hugovk hugovk added the pending The issue will be closed if no feedback is provided label Dec 19, 2023
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes and removed needs backport to 3.11 only security fixes labels May 9, 2024
@nineteendo
Copy link
Contributor

Do we close this or do we remove the pending label?

Copy link
Member

@vadmium vadmium left a comment

Choose a reason for hiding this comment

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

I think the current proposed changes should fix the firewall problem as I understand it. The changes are a bit clumsy, but overall beneficial.

I don’t see any reason why the problem would already be fixed. Maybe @terryjreedy it’s just that you originally had a firewall interfering, but it isn’t any more?

self.send_response(HTTPStatus.OK)
self.send_header('Content-Length', 0)
Copy link
Member

Choose a reason for hiding this comment

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

(Nitpick) It’s not really documented, and seems to work regardless, but I assume the header field value should be a string '0' not an integer

# To combat this, we send the test server the "Connection" header
# with "close" for the value forcing the server and client to
# terminate the socket allowing the test to resume.
self.con.request('GET', '/', headers={'Connection': 'close'})
Copy link
Member

Choose a reason for hiding this comment

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

The explanation seems vague. I would explain it as:

“Connection: close” causes the server to set its “close_connection” flag. If the client did not also shut down the connection below, this flag would avoid a deadlock between the server waiting for a second request on the connection, and the main thread shutting the server down.

@terryjreedy
Copy link
Member

I have no idea why the test failed and then passed again on my machine. It works now as is on a debug no-gil build. I do know that code can be improved, and maybe made more stable, even if not failing on a particular machine at a particular time. Please judge on that basis. I also know that tests that pass on GH CI machines may fail on my machine, and vice versa, and need revision to run better on both and others.

Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Feb 27, 2025
@hugovk hugovk removed the needs backport to 3.12 only security fixes label Apr 10, 2025
@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Apr 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting core review needs backport to 3.13 bugs and security fixes pending The issue will be closed if no feedback is provided skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.