Implementation of select.poll on Microsoft Windows.
- Pure Python; no C extensions (uses
ctypes.windll.Ws2_32) - Drop-in-compatible API
- Clean "ponyfill"; library does no monkeypatching
- Python 3.7+ compatible
- No dependencies
Usage
Alternative to select.poll
try:
from select import (
POLLIN, POLLOUT, POLLERR, POLLHUP, POLLNVAL,
poll
)
except ImportError:
# https://github.com/python/cpython/issues/60711
from winpoll import (
POLLIN, POLLOUT, POLLERR, POLLHUP, POLLNVAL,
wsapoll as poll
)
p = poll()
p.register(sock1, POLLIN)
p.register(sock2, POLLIN | POLLOUT)
p.unregister(sock1)
for fd, events in p.poll(3):
print(f"<socket.socket fd={fd}> is ready with {events}")
Like select.poll, winpoll.wsapoll objects acquire no special resources, thus
have no cleanup requirement (besides plain garbage collection).
Alternative to selectors.PollSelector/selectors.DefaultSelector
import sys
from selectors import (
EVENT_READ, EVENT_WRITE,
DefaultSelector, SelectSelector
)
if (DefaultSelector is SelectSelector) and (sys.platform == 'win32') and (sys.getwindowsversion() >= (10, 0, 19041)):
# https://github.com/python/cpython/issues/60711
from winpoll import WSAPollSelector as DefaultSelector
s = DefaultSelector()
s.register(sock1, EVENT_READ)
s.register(sock2, EVENT_READ | EVENT_WRITE)
s.unregister(sock1)
for (sock, _fd, _eventmask, _data), events in s.select(3):
print(f"{sock} is ready with {events}")
Limitations / Bugs
-
Does not work before Windows Vista.
- Last affected OS: Windows XP (EOL April 8, 2014; not supported by Python 3.7+ anyway.)
-
Outbound TCP connections don't correctly report failure-to-connect (
(POLLHUP | POLLERR | POLLWRNORM)) before Windows 10 version 2004 ("May 2020 Update" / "20H1" / "OS Build 19041").- Last affected OS: Windows 10 version 1909 (EOL May 10, 2022.)
Installation
Command-line
pip install "winpoll ; sys_platform == 'win32'"
requirements.txt
...
winpoll ; sys_platform == 'win32'
setup.py
...
setup(
...,
install_requires: [
...,
"winpoll ; sys_platform == 'win32'"
]
)
pyproject.toml
[project]
...
dependencies = [
...,
"winpoll ; sys_platform == 'win32'",
]
Metadata
Release files for winpoll 0.20301.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| winpoll-0.20301.3.tar.gz | 10.6 kB | Without provenance | Details for winpoll-0.20301.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| winpoll-0.20301.3-py3-none-any.whl | Python 3 | none | any | Details for winpoll-0.20301.3-py3-none-any.whl |
Total release size: 22.8 kB
Release files / winpoll-0.20301.3.tar.gz
| Download URL | winpoll-0.20301.3.tar.gz |
|---|---|
| Size | 10.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ed99e1f26378f94dd885c78c502cab8f8e4cdf7f5305d39dba8d8fc68a8376ca
|
|
BLAKE2b-256 checksum How to use checksums |
6cce0ac13897f573d2a6f9ebac9fb67ed3e0c9514def906adf24662e4efc7806
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.9
|
Release files / winpoll-0.20301.3-py3-none-any.whl
| Download URL | winpoll-0.20301.3-py3-none-any.whl |
|---|---|
| Size | 12.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e6cd4c728056460a9aa5bdad11353639f6ba8c2df022eecd24733c0e8ad54ba4
|
|
BLAKE2b-256 checksum How to use checksums |
3abb127203e3d4488f8f3e250dcff990942415a46f4a9d521309eb586246fa6e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.9
|
Security for winpoll 0.20301.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.