René's URL Explorer Experiment


Title: Rustls integration improvements by im-0 · Pull Request #7946 · RustPython/RustPython · GitHub

Open Graph Title: Rustls integration improvements by im-0 · Pull Request #7946 · RustPython/RustPython

X Title: Rustls integration improvements by im-0 · Pull Request #7946 · RustPython/RustPython

Description: Primary goal of this PR is to fix #7891 Changes: Do not call import socket on each send()/recv() when using rustls Implement reading of at most one TLS record from socket. Previous algorithm didn't take into account that recv() may return less data than requested even for blocking sockets Remove special handling of rustls "buffer full" errors. One of that checks is a root cause of a hang with 100% CPU core utilization. This PR also adds a regression test for this particular problem. Replace own TlsConnection with rustls::Connection Dead code removed rustls errors are no longer presented as as OSError(0, "Success") Infinite loop "detection" removed from rustls handshake code. TLS handshake cannot be infinite. Any infinite loop here is a serious bug in implementation and should be fixed properly. Also, this code triggered in some cases (very short reads) with misleading ssl_error.SSLWantReadError: The operation did not complete (read). Deduplicated verify flags / record-size constants Used slightly larger "max encrypted TLS record length" from OpenSSL headers Socket wait fixes: socket_wait() called from TLS glue code now allows threads (vm.allow_threads()) socket_wait() called from TLS glue code now properly handles EINTR on *nix select()/poll() error conditions are checked poll() is used on *nix so socket descriptor values are not limited to

Open Graph Description: Primary goal of this PR is to fix #7891 Changes: Do not call import socket on each send()/recv() when using rustls Implement reading of at most one TLS record from socket. Previous algorithm didn&...

X Description: Primary goal of this PR is to fix #7891 Changes: Do not call import socket on each send()/recv() when using rustls Implement reading of at most one TLS record from socket. Previous algorithm didn&...

Opengraph URL: https://github.com/RustPython/RustPython/pull/7946

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:2510bc64-8386-165a-9476-2b1f9499aee6
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idCFFC:18C6F1:2C854D:3C6022:6A5FF007
html-safe-nonce824f1743215eb8cc91bc5435d736c5ebf557705bd90be9eeeec034882253818d
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRkZDOjE4QzZGMToyQzg1NEQ6M0M2MDIyOjZBNUZGMDA3IiwidmlzaXRvcl9pZCI6Ijk2MzU2MDUxNzE4NDUxNjEwMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac29549280ade9d408f6584e7e9685fdad48c76785e859d95e3c4c44a02ae0d431
hovercard-subject-tagpull_request:3723220654
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/RustPython/RustPython/pull/7946/files
twitter:imagehttps://avatars.githubusercontent.com/u/18099621?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/18099621?s=400&v=4
og:image:altPrimary goal of this PR is to fix #7891 Changes: Do not call import socket on each send()/recv() when using rustls Implement reading of at most one TLS record from socket. Previous algorithm didn&...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noneba296ecd3a3521238fe43b3b3b08cc09207ddc21173e16ee656db03803de8e2b
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git
octolytics-dimension-user_id39710557
octolytics-dimension-user_loginRustPython
octolytics-dimension-repository_id135201145
octolytics-dimension-repository_nwoRustPython/RustPython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id135201145
octolytics-dimension-repository_network_root_nwoRustPython/RustPython
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release6e50fb37e29e4aa0df6386cb485e58b0e3ca97ab
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/RustPython/RustPython/pull/7946/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fpull%2F7946%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fpull%2F7946%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=RustPython%2FRustPython
Reloadhttps://github.com/RustPython/RustPython/pull/7946/files
Reloadhttps://github.com/RustPython/RustPython/pull/7946/files
Reloadhttps://github.com/RustPython/RustPython/pull/7946/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/7946/files
RustPython https://github.com/RustPython
RustPythonhttps://github.com/RustPython/RustPython
Notifications https://github.com/login?return_to=%2FRustPython%2FRustPython
Fork 1.5k https://github.com/login?return_to=%2FRustPython%2FRustPython
Star 22.2k https://github.com/login?return_to=%2FRustPython%2FRustPython
Code https://github.com/RustPython/RustPython
Issues 294 https://github.com/RustPython/RustPython/issues
Pull requests 105 https://github.com/RustPython/RustPython/pulls
Discussions https://github.com/RustPython/RustPython/discussions
Actions https://github.com/RustPython/RustPython/actions
Projects https://github.com/RustPython/RustPython/projects
Models https://github.com/RustPython/RustPython/models
Wiki https://github.com/RustPython/RustPython/wiki
Security and quality 0 https://github.com/RustPython/RustPython/security
Insights https://github.com/RustPython/RustPython/pulse
Code https://github.com/RustPython/RustPython
Issues https://github.com/RustPython/RustPython/issues
Pull requests https://github.com/RustPython/RustPython/pulls
Discussions https://github.com/RustPython/RustPython/discussions
Actions https://github.com/RustPython/RustPython/actions
Projects https://github.com/RustPython/RustPython/projects
Models https://github.com/RustPython/RustPython/models
Wiki https://github.com/RustPython/RustPython/wiki
Security and quality https://github.com/RustPython/RustPython/security
Insights https://github.com/RustPython/RustPython/pulse
Sign up for GitHub https://github.com/signup?return_to=%2FRustPython%2FRustPython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2FRustPython%2FRustPython%2Fissues%2Fnew%2Fchoose
youknowonehttps://github.com/youknowone
RustPython:mainhttps://github.com/RustPython/RustPython/tree/main
im-0:fix-rustlshttps://github.com/im-0/RustPython/tree/fix-rustls
Conversation 17 https://github.com/RustPython/RustPython/pull/7946
Commits 11 https://github.com/RustPython/RustPython/pull/7946/commits
Checks 25 https://github.com/RustPython/RustPython/pull/7946/checks
Files changed https://github.com/RustPython/RustPython/pull/7946/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/7946/files
Rustls integration improvements https://github.com/RustPython/RustPython/pull/7946/files#top
Show all changes 11 commits https://github.com/RustPython/RustPython/pull/7946/files
ad3060c Do not call `import socket` on each send()/recv() when using rustls im-0 May 18, 2026 https://github.com/RustPython/RustPython/pull/7946/commits/ad3060ca823fd78081ef8249e6e492d77336db23
7fa757d Implement reading of at most one TLS record from socket im-0 May 18, 2026 https://github.com/RustPython/RustPython/pull/7946/commits/7fa757dec36bd7a780562ea1316332eb54416942
bc2dbf9 Remove special handling of rustls "buffer full" errors im-0 May 19, 2026 https://github.com/RustPython/RustPython/pull/7946/commits/bc2dbf98f69e0168debc052a64dfb9a91251edd4
023c754 Replace own TlsConnection with rustls::Connection im-0 May 19, 2026 https://github.com/RustPython/RustPython/pull/7946/commits/023c75440db352a9f35a42d7f360d3b30ff2ce06
e99f0c4 Fix waiting on a socket im-0 May 19, 2026 https://github.com/RustPython/RustPython/pull/7946/commits/e99f0c4103812562dc2af5f3817b972758bade31
e9e359c Remove dead code from rustls glue im-0 May 20, 2026 https://github.com/RustPython/RustPython/pull/7946/commits/e9e359cb00b51e4a4c7af89c03318a016992bd5b
7a10b53 Do not present rustls errors as OSError(0, "Success") im-0 May 21, 2026 https://github.com/RustPython/RustPython/pull/7946/commits/7a10b53ba0369d56ef0adebc8b530929079e6937
86ec36b Remove infinite loop "detection" from rustls glue im-0 May 21, 2026 https://github.com/RustPython/RustPython/pull/7946/commits/86ec36b3111c1fde7f022818db06b055f36303f9
fbe1f80 Add test for 1-byte max recv in TLS client im-0 May 21, 2026 https://github.com/RustPython/RustPython/pull/7946/commits/fbe1f8068a18e6103f1705ee0449f02bf21313c5
6905963 Add regression test for https://github.com/RustPython/RustPython/issu… im-0 May 21, 2026 https://github.com/RustPython/RustPython/pull/7946/commits/6905963c9f86ad5c87744ad23c975db1f27c1166
6c0e292 Fix constants in rustls glue code im-0 May 21, 2026 https://github.com/RustPython/RustPython/pull/7946/commits/6c0e29287f71ef84ec9b84039bcfe7c141e5172a
Clear filters https://github.com/RustPython/RustPython/pull/7946/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/7946/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/7946/files
socket.rs https://github.com/RustPython/RustPython/pull/7946/files#diff-e700a2482e618f0d67e0b1f7bbc4e5eef1bc7da702aaef7fa30d487372d19b72
socket.rs https://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
ssl.rs https://github.com/RustPython/RustPython/pull/7946/files#diff-454ec133e37f245b8eb2dfcd83daf62e341eb3ab03b353d30297ae029e73213b
cert.rs https://github.com/RustPython/RustPython/pull/7946/files#diff-abc8fe978cbea5cc2805b8d5d2fc2f07b2a4975261400f4c47b94470a0c33244
compat.rs https://github.com/RustPython/RustPython/pull/7946/files#diff-2e4dbb35c6460c23af1a8d48d17e0f8ddf604328016b018c184da5b1fdcd2cc2
error.rs https://github.com/RustPython/RustPython/pull/7946/files#diff-f1ae75050e2a66c3b2ec9d55a0d74899f086e471f267a97d5a668c514a1d46db
stdlib_ssl_short_recv.py https://github.com/RustPython/RustPython/pull/7946/files#diff-6debe55104b06d6397801279066fc9350f1018e933d24521d326d6d387b42930
stdlib_urllib_https_misaligned_recv.py https://github.com/RustPython/RustPython/pull/7946/files#diff-be15f98a2b406d918fe7bf953560a048c75156ecdad67a939080b687fc7d9025
crates/host_env/src/socket.rshttps://github.com/RustPython/RustPython/pull/7946/files#diff-e700a2482e618f0d67e0b1f7bbc4e5eef1bc7da702aaef7fa30d487372d19b72
View file https://github.com/im-0/RustPython/blob/6c0e29287f71ef84ec9b84039bcfe7c141e5172a/crates/host_env/src/socket.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/7946/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/7946/files#diff-e700a2482e618f0d67e0b1f7bbc4e5eef1bc7da702aaef7fa30d487372d19b72
https://github.com/RustPython/RustPython/pull/7946/files#diff-e700a2482e618f0d67e0b1f7bbc4e5eef1bc7da702aaef7fa30d487372d19b72
https://github.com/RustPython/RustPython/pull/7946/files#diff-e700a2482e618f0d67e0b1f7bbc4e5eef1bc7da702aaef7fa30d487372d19b72
https://github.com/RustPython/RustPython/pull/7946/files#diff-e700a2482e618f0d67e0b1f7bbc4e5eef1bc7da702aaef7fa30d487372d19b72
crates/stdlib/src/socket.rshttps://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
View file https://github.com/im-0/RustPython/blob/6c0e29287f71ef84ec9b84039bcfe7c141e5172a/crates/stdlib/src/socket.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/7946/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
https://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
https://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
https://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
https://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
https://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
https://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
https://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
https://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
https://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
https://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
https://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
https://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
https://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
https://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
https://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
https://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
https://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
https://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
https://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
https://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
https://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
https://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
https://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
https://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
https://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
https://github.com/RustPython/RustPython/pull/7946/files#diff-184374c26b267e900965c88a05d2c963f9c2fcdc8419201b0fa39b9ed462b5c7
Please reload this pagehttps://github.com/RustPython/RustPython/pull/7946/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/7946/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.