winpoll


Namewinpoll JSON
Version 0.20301.3 PyPI version JSON
download
home_pageNone
SummaryImplementation of `select.poll` on Microsoft Windows.
upload_time2025-08-01 17:28:59
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseNone
keywords poll select.poll wsapoll windows polyfill windows ponyfill
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            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`

```python
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
    )
```

```python
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`

```python
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
```

```python
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](https://learn.microsoft.com/en-us/lifecycle/announcements/windows-xp-office-exchange-2003-end-of-support); 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](https://learn.microsoft.com/en-us/lifecycle/announcements/windows-10-1909-enterprise-education-eos).)


# Installation

## Command-line

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

## `requirements.txt`

```ini
...
winpoll ; sys_platform == 'win32'
```

## `setup.py`
```py
...

setup(
    ...,
    install_requires: [
        ...,
        "winpoll ; sys_platform == 'win32'"
    ]
)
```

## `pyproject.toml`

```toml
[project]
...

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

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "winpoll",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "poll, select.poll, WSAPoll, Windows polyfill, Windows ponyfill",
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/6c/ce/0ac13897f573d2a6f9ebac9fb67ed3e0c9514def906adf24662e4efc7806/winpoll-0.20301.3.tar.gz",
    "platform": null,
    "description": "Implementation of `select.poll` on Microsoft Windows.\r\n\r\n- Pure Python; no C extensions (uses `ctypes.windll.Ws2_32`)\r\n- Drop-in-compatible API\r\n- Clean \"ponyfill\"; library does no monkeypatching\r\n- Python 3.7+ compatible\r\n- No dependencies\r\n\r\n\r\n# Usage\r\n\r\n## Alternative to `select.poll`\r\n\r\n```python\r\ntry:\r\n    from select import (\r\n        POLLIN, POLLOUT, POLLERR, POLLHUP, POLLNVAL,\r\n        poll\r\n    )\r\n\r\nexcept ImportError:\r\n    # https://github.com/python/cpython/issues/60711\r\n    from winpoll import (\r\n        POLLIN, POLLOUT, POLLERR, POLLHUP, POLLNVAL,\r\n        wsapoll as poll\r\n    )\r\n```\r\n\r\n```python\r\np = poll()\r\n\r\np.register(sock1, POLLIN)\r\np.register(sock2, POLLIN | POLLOUT)\r\np.unregister(sock1)\r\n\r\nfor fd, events in p.poll(3):\r\n    print(f\"<socket.socket fd={fd}> is ready with {events}\")\r\n```\r\n\r\nLike `select.poll`, `winpoll.wsapoll` objects acquire no special resources, thus\r\nhave no cleanup requirement (besides plain garbage collection).\r\n\r\n## Alternative to `selectors.PollSelector`/`selectors.DefaultSelector`\r\n\r\n```python\r\nimport sys\r\nfrom selectors import (\r\n    EVENT_READ, EVENT_WRITE,\r\n    DefaultSelector, SelectSelector\r\n)\r\n\r\nif (DefaultSelector is SelectSelector) and (sys.platform == 'win32') and (sys.getwindowsversion() >= (10, 0, 19041)):\r\n    # https://github.com/python/cpython/issues/60711\r\n    from winpoll import WSAPollSelector as DefaultSelector\r\n```\r\n\r\n```python\r\ns = DefaultSelector()\r\n\r\ns.register(sock1, EVENT_READ)\r\ns.register(sock2, EVENT_READ | EVENT_WRITE)\r\ns.unregister(sock1)\r\n\r\nfor (sock, _fd, _eventmask, _data), events in s.select(3):\r\n    print(f\"{sock} is ready with {events}\")\r\n```\r\n\r\n\r\n# Limitations / Bugs\r\n\r\n- Does not work before Windows Vista.\r\n\r\n  * Last affected OS: Windows XP ([EOL April 8, 2014](https://learn.microsoft.com/en-us/lifecycle/announcements/windows-xp-office-exchange-2003-end-of-support); not supported by Python 3.7+ anyway.)\r\n\r\n- 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\").\r\n\r\n  * Last affected OS: Windows 10 version 1909 ([EOL May 10, 2022](https://learn.microsoft.com/en-us/lifecycle/announcements/windows-10-1909-enterprise-education-eos).)\r\n\r\n\r\n# Installation\r\n\r\n## Command-line\r\n\r\n```cmd\r\npip install \"winpoll ; sys_platform == 'win32'\"\r\n```\r\n\r\n## `requirements.txt`\r\n\r\n```ini\r\n...\r\nwinpoll ; sys_platform == 'win32'\r\n```\r\n\r\n## `setup.py`\r\n```py\r\n...\r\n\r\nsetup(\r\n    ...,\r\n    install_requires: [\r\n        ...,\r\n        \"winpoll ; sys_platform == 'win32'\"\r\n    ]\r\n)\r\n```\r\n\r\n## `pyproject.toml`\r\n\r\n```toml\r\n[project]\r\n...\r\n\r\ndependencies = [\r\n  ...,\r\n  \"winpoll ; sys_platform == 'win32'\",\r\n]\r\n```\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Implementation of `select.poll` on Microsoft Windows.",
    "version": "0.20301.3",
    "project_urls": null,
    "split_keywords": [
        "poll",
        " select.poll",
        " wsapoll",
        " windows polyfill",
        " windows ponyfill"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "3abb127203e3d4488f8f3e250dcff990942415a46f4a9d521309eb586246fa6e",
                "md5": "bf986445d610c7312b28c81ad58b2636",
                "sha256": "e6cd4c728056460a9aa5bdad11353639f6ba8c2df022eecd24733c0e8ad54ba4"
            },
            "downloads": -1,
            "filename": "winpoll-0.20301.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bf986445d610c7312b28c81ad58b2636",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 12210,
            "upload_time": "2025-08-01T17:28:58",
            "upload_time_iso_8601": "2025-08-01T17:28:58.792599Z",
            "url": "https://files.pythonhosted.org/packages/3a/bb/127203e3d4488f8f3e250dcff990942415a46f4a9d521309eb586246fa6e/winpoll-0.20301.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "6cce0ac13897f573d2a6f9ebac9fb67ed3e0c9514def906adf24662e4efc7806",
                "md5": "c88499139b6402148ed0e085bc217fcc",
                "sha256": "ed99e1f26378f94dd885c78c502cab8f8e4cdf7f5305d39dba8d8fc68a8376ca"
            },
            "downloads": -1,
            "filename": "winpoll-0.20301.3.tar.gz",
            "has_sig": false,
            "md5_digest": "c88499139b6402148ed0e085bc217fcc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 10558,
            "upload_time": "2025-08-01T17:28:59",
            "upload_time_iso_8601": "2025-08-01T17:28:59.685341Z",
            "url": "https://files.pythonhosted.org/packages/6c/ce/0ac13897f573d2a6f9ebac9fb67ed3e0c9514def906adf24662e4efc7806/winpoll-0.20301.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-01 17:28:59",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "winpoll"
}
        
Elapsed time: 1.42876s