skillfed

selectors2

Back-ported, durable, and portable selectors

selectors2 v2.0.2 159.3K downloads/30d#10,702 on PyPI14
Permissive license MIT Abandoned released

What it is and what it does

Selectors2 is a backport of Python's selectors module designed for older Python versions (2.6–3.4) and Jython. It provides a unified API for monitoring file descriptors (sockets and pipes) for I/O readiness across different operating systems by selecting the best available selector type—epoll on Linux, kqueue on BSD/macOS, poll on some Unix systems, or the portable select() fallback. The package implements PEP 475 to handle interrupted system calls gracefully, retrying rather than returning spurious empty events.

The module is a drop-in replacement for the standard library selectors module and was originally developed to solve real-world durability and portability problems. It supports monkey-patching scenarios and detects systems that claim to support a selector but don't actually implement it. However, the package has been abandoned since July 21, 2020 and receives no maintenance; modern Python users should use the standard library selectors module instead.

Use it for:

  • Porting async I/O code to Python 2.6–3.4 environments where the standard selectors module is unavailable or incomplete.
  • Building network libraries that need robust selector support across Linux, macOS, Windows, and Jython without external async frameworks.
  • Handling interrupted system calls reliably in older Python versions that predate PEP 475.
  • Monitoring multiple sockets or pipes for read/write events in legacy applications that cannot upgrade Python versions.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides a backported, cross-platform replacement for Python's standard library selectors module, supporting multiple selector types (epoll, kqueue, poll, select) across Linux, macOS, Windows, and Jython.

No, unless you are maintaining legacy Python 2.6–3.4 code that requires selector functionality and cannot use the standard library module. The package is abandoned (last release July 21, 2020, repository archived) and receives no security or maintenance updates. Modern Python users should use the standard library selectors module instead.

Install

selectors2 on PyPI

pip

pip install selectors2

uv

uv add selectors2

poetry

poetry add selectors2

Installing selectors2

Before you install

Low install friction with no runtime dependencies. However, the package is abandoned as of July 21, 2020 and its repository is archived. Use only if you need Python 2.6–3.4 support or cannot upgrade to the standard library selectors module.

License in practice

Dual-licensed under MIT and PSF License, both permissive. You may use, modify, and distribute this package freely in commercial or private projects with minimal restrictions.

Quickstart

import selectors2 as selectors

s = selectors.DefaultSelector()
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.register(sock, selectors.EVENT_WRITE)
events = s.select(timeout=1.0)
for key, event in events:
    if event & selectors.EVENT_WRITE:
        key.fileobj.send(b'data')

Requires a platform with a selector available (select.select, epoll, kqueue, poll, or devpoll); raises RuntimeError on platforms without any selector.

Verify before relying

  • Whether PEP 475 interrupt-retry behavior remains necessary in modern Python versions.
  • Current real-world adoption outside of legacy Python 2 codebases.
  • Compatibility with Python versions beyond 3.4 despite abandonment.

Package facts

License MIT (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance abandoned — 2,215 days since the last release
Last repo commit (repository archived)
First released
Downloads 159,258/month — #10,702 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: selectors2-2.0.2-py2.py3-none-any.whl

Keywords: async, file, socket, select, backport

License :: OSI Approved :: MIT LicenseLicense :: OSI Approved :: Python Software Foundation LicenseProgramming Language :: Python :: 2Programming Language :: Python :: 2.6Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.3Programming Language :: Python :: 3.4

Tags

backported selectors modulecross-platform socket selectionepoll kqueue poll selectasync I/O selectorfile descriptor monitoringpython 2 selectors backportportable event loop selector
backportlegacy-pythonabandoned

More Networking packages