Skip to main content

notwork

Python functions for when your network might notwork.

Read the documentation at cariad.github.io/notwork.

Installation

notwork needs Python 3.14 or later, and has no dependencies.

pip install notwork

Or with uv:

uv add notwork

Usage

Check a port number

is_port_in_range says whether a port number is valid, and check_port_is_in_range raises PortOutOfRangeError when it isn't.

from notwork import check_port_is_in_range, is_port_in_range

is_port_in_range(8000)
# True

check_port_is_in_range(70000)
# PortOutOfRangeError: Port 70000 must be 1-65535

Check for IPv6

has_ipv6 says whether this machine can bind ::1, the IPv6 loopback address.

from notwork import has_ipv6

has_ipv6()
# True when this machine can bind ::1

Claim a port

claim_port claims a port on every address that localhost can mean, and returns a ClaimedPort to listen on.

If another program is already using the port on localhost, it raises PortInUseError.

On Linux, the sockets are already listening when they're returned. On Windows, another program can still bind the port on :: with a socket that accepts IPv4 and IPv6 at once.

from notwork import claim_port

with claim_port(8000) as port:
    # Bound to 127.0.0.1, and ::1 when there's IPv6
    for sock in port.sockets:
        sock.listen()

# Leaving the `with` block closed the port.

Metadata

Release files for notwork 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for notwork 1.1.0
File Size Uploaded Provenance Actions
notwork-1.1.0.tar.gz 53.1 kB With provenance Details for notwork-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for notwork 1.1.0
File Interpreter ABI Platform Actions
notwork-1.1.0-py3-none-any.whl Python 3 none any Details for notwork-1.1.0-py3-none-any.whl

Total release size: 64.5 kB

Release files / notwork-1.1.0.tar.gz

Download URL notwork-1.1.0.tar.gz
Size 53.1 kB
Tags Source
SHA-256 checksum
How to use checksums
41a763263a3403af432a70f6e23b007abfccaf0fde6aeea007f106b9dede32f1
BLAKE2b-256 checksum
How to use checksums
ed329748969ad11f8fdfade11fe3862e579bb6be2f67116f25aa89593f4e46ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Release files / notwork-1.1.0-py3-none-any.whl

Download URL notwork-1.1.0-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ee0f2e9e52ac52f94651b8896369f965d8bef887dfab7214642861ea7d38716
BLAKE2b-256 checksum
How to use checksums
2ca53737c318edba816bbc5e1f4fe389495ad65735489489b96a0a7d19ebd77a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Security for notwork 1.1.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for notwork-1.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page