Skip to main content
https://img.shields.io/pypi/v/portend.svg https://img.shields.io/pypi/pyversions/portend.svg tests Ruff https://readthedocs.org/projects/portend/badge/?version=latest https://img.shields.io/badge/skeleton-2025-informational https://tidelift.com/badges/package/pypi/portend

por·tend pôrˈtend/ verb

be a sign or warning that (something, especially something momentous or calamitous) is likely to happen.

Usage

Use portend to monitor TCP ports for bound or unbound states.

For example, to wait for a port to be occupied, timing out after 3 seconds:

portend.occupied('www.google.com', 80, timeout=3)

Or to wait for a port to be free, timing out after 5 seconds:

portend.free('::1', 80, timeout=5)

The portend may also be executed directly. If the function succeeds, it returns nothing and exits with a status of 0. If it fails, it prints a message and exits with a status of 1. For example:

python -m portend localhost:31923 free
(exits immediately)

python -m portend -t 1 localhost:31923 occupied
(one second passes)
Port 31923 not bound on localhost.

Portend also exposes a find_available_local_port for identifying a suitable port for binding locally:

port = portend.find_available_local_port()
print(port, "is available for binding")

Portend additionally exposes the lower-level port checking functionality in the Checker class, which currently exposes only one public method, assert_free:

portend.Checker().assert_free('localhost', 31923)

If assert_free is passed a host/port combination that is occupied by a bound listener (i.e. a TCP connection is established to that host/port), assert_free will raise a PortNotFree exception.

For Enterprise

Available as part of the Tidelift Subscription.

This project and the maintainers of thousands of other packages are working with Tidelift to deliver one enterprise subscription that covers all of the open source you use.

Learn more.

Release files for portend 3.2.1

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

Source distribution (sdist)

Source distribution for portend 3.2.1
File Size Uploaded
portend-3.2.1.tar.gz 12.2 kB Details

Built distribution (wheel)

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

Total release size: 17.9 kB

Release files / portend-3.2.1.tar.gz

Download URL portend-3.2.1.tar.gz
Size 12.2 kB
Tags Source
SHA-256 checksum
How to use checksums
aa9d40ab1f9e14bdb7d401f42210df35d017c9b97991baeb18568cedfb8c6489
BLAKE2b-256 checksum
How to use checksums
b757be90f42996fc4f57d5742ef2c95f7f7bb8e9183af2cc11bff8e7df338888
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release files / portend-3.2.1-py3-none-any.whl

Download URL portend-3.2.1-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bd2bb1cd8585e32f1f986c1b8eae2950c8622c648db163b711a2fc2ef8d8d492
BLAKE2b-256 checksum
How to use checksums
4911b0b19077f80cb8972b44c96af983e8cfcdb1506090bacef137ed8b448af8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release history Release notifications | RSS feed

This release

3.2.1 This release

2 release files

3.2.0

2 release files

3.1.0

2 release files

3.0.0

2 release files

2.7.2

2 release files

2.7.1

2 release files

2.7.0

2 release files

2.6

2 release files

2.5

2 release files

2.4

2 release files

2.3

2 release files

2.2

2 release files

2.1.2

2 release files

2.1.1

2 release files

2.1

2 release files

1.8

2 release files

1.7.1

2 release files

1.7

2 release files

1.6.1

2 release files

1.6

2 release files

1.5.1

2 release files

1.4

2 release files

1.3

1 release file

1.2

1 release file

1.1.3

1 release file

1.1.1

1 release file

1.1

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0

1 release file

0.0.0

2 release files

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