python / python/cpython

Should `socketserver.BaseServer` have abstract methods?

Open
#127,209 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib topic-socket type-feature
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Feature or enhancement

Proposal:

socketserver.BaseServer is documented to have the methods fileno, get_request, and server_bind, but it doesn't actually have these. They're implemented on the subclass TCPServer instead, and TCPServer is the only direct subclass of BaseServer in the standard library. Of the three methods, get_request is the only one called within any existing methods of BaseServer.

This seems like a situation where BaseServer is acting as an ABC with these methods expected to be implemented by any subclass. Abstract methods weren't available yet when socketserver was added. Does it make sense to use them now? I couldn't find anyone suggesting this on the issue tracker or on discuss.python.org, so I don't know if this has been considered and rejected before, or never really considered.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs
  • gh-127976

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the socketserver.BaseServer and TCPServer entry points, focusing on fileno, get_request, and server_bind and how BaseServer currently uses them. Review linked PR gh-127976 and determine whether making these methods abstract preserves the documented subclass contract; done means reaching a documented decision with corresponding implementation and validation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.