Skip to main content

Implementation of `select.poll` on Microsoft Windows.

Project description

Implementation of select.poll on Microsoft Windows.

  • Pure Python; no C extensions (uses ctypes.windll.Ws2_32)
  • Drop-in-compatible API
  • Clean "ponyfill"; no monkeypatching
  • No dependencies (besides Windows Vista or newer)
  • Python 3.6+ compatible

Usage

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 sock, events in p.poll(timeout=3):
    print(f"Socket {sock} is ready with {events}")

Like select.poll, winpoll.wsapoll objects acquire no special resources, thus have no cleanup requirement (besides plain garbage collection).

Limitations / Bugs

  • Does not work before Windows Vista.

  • Outbound TCP connections don't correctly report failure-to-connect ((POLLHUP | POLLERR | POLLWRNORM)) before Windows 10 Version 2004 (OS build 19041).

Installation

Command-line

pip install "winpoll ; sys_platform == 'win32'"

requirements.txt

winpoll ; sys_platform == 'win32'

pyproject.toml

[project]
dependencies = [
  ...,
  "winpoll ; sys_platform == 'win32'",
]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

winpoll-0.20294.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

winpoll-0.20294.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file winpoll-0.20294.0.tar.gz.

File metadata

  • Download URL: winpoll-0.20294.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for winpoll-0.20294.0.tar.gz
Algorithm Hash digest
SHA256 dee1a69a492aa83913f1c3fb47415d38e60fc538d910b0efedf01545efd09fef
MD5 43056e82e8f2c60cffe4e5dedd5a3f2d
BLAKE2b-256 385b4571c918a17664ad586c0146aa87f7400cef64229d15b52501cc3e9484f5

See more details on using hashes here.

File details

Details for the file winpoll-0.20294.0-py3-none-any.whl.

File metadata

  • Download URL: winpoll-0.20294.0-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for winpoll-0.20294.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8001319e765cacb1c6b224aa1d14c8a067e47bb355880c76470f50514147c9a9
MD5 905e64ed66b2b554a11a1bcb2a918189
BLAKE2b-256 3bc2a8c9ed7ad209bcb4d7223ba99b743413a678e63ce5540d47407ebed4b90e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page