Skip to content

gh-142403: Avoid leaking file descriptor in socket.py#142404

Open
AZero13 wants to merge 1 commit into
python:mainfrom
AZero13:file-descriptor
Open

gh-142403: Avoid leaking file descriptor in socket.py#142404
AZero13 wants to merge 1 commit into
python:mainfrom
AZero13:file-descriptor

Conversation

@AZero13

@AZero13 AZero13 commented Dec 8, 2025

Copy link
Copy Markdown
Contributor

@bedevere-app

bedevere-app Bot commented Dec 8, 2025

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@aisk

This comment was marked as resolved.

@StanFromIreland StanFromIreland changed the title Avoid leaking file descriptor in socket.py gh-142403: Avoid leaking file descriptor in socket.py Dec 8, 2025
@StanFromIreland

Copy link
Copy Markdown
Member

Please add a NEWS like as the bot requested.

@aisk aisk removed the skip news label Dec 9, 2025
@bedevere-app

bedevere-app Bot commented Dec 9, 2025

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@aisk

aisk commented Dec 10, 2025

Copy link
Copy Markdown
Member

Hi @AZero13 , according to the devguide, force push should be avoided.

Comment thread Lib/socket.py
if hasattr(selectors, 'PollSelector'):
selector = selectors.PollSelector()
else:
selector = selectors.SelectSelector()

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.

I would prefer to keep this code to create the selector, it's more readable.

Comment thread Lib/socket.py
selectors.PollSelector()
if hasattr(selectors, 'PollSelector')
else selectors.SelectSelector()
) as selector:

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.

I would prefer to use with selector: here.

@@ -0,0 +1 @@
Stop leaking the selector file descriptor, and release it when done.

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.

Are you sure that there is a leak of a file descriptor? The selectors used by _sendfile_zerocopy() don't use a file descriptor: #142403 (comment)

@github-actions

github-actions Bot commented May 3, 2026

Copy link
Copy Markdown

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 May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants