Registry / http-networking / ephemeral-port-reserve

ephemeral-port-reserve

JSON →
library1.1.4pypypi✓ verified 85d ago

A small Python library that binds to an ephemeral port, forces it into the TIME_WAIT state, and then unbinds, making the port reserved for use by the caller without interference. Current version 1.1.4, maintenance mode with no active development.

pip install ephemeral-port-reserve
INSTALL
IMPORT
SIG · EPHEMERAL-PORT-RES
E
ephemeral-port-reserve
http-networkingpythonv1.1.4
Install
1.5s avg
Import
10ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.010s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.010s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

reserve
from ephemeral_port_reserve import reserve
from ephemeral_port_reserve import reserve
This is the only public API. No common mistakes, but ensure import matches exactly.

Reserve an ephemeral port using the reserve() function. Port is automatically released on process exit.

from ephemeral_port_reserve import reserve # Reserve an ephemeral port port = reserve() print(f"Reserved port: {port}") # Use the port... # No explicit release needed; the reservation vanishes when the process exits.
Debug
Known issues
gotchaThe reserved port is only guaranteed to be available for the lifetime of the calling process. Once the process exits, the port may be reused by the OS or another process.
fix
Ensure your process holds the reservation for the duration needed. Do not rely on cross-process persistence.
affects: all
gotchaOn some systems (e.g., Linux), the reservation may fail if the system is under heavy load or if ephemeral port range is exhausted. The function raises an exception in such cases.
fix
Handle exceptions from reserve() and implement retry logic or fallback mechanisms.
affects: all
deprecatedThe library is in maintenance mode and is not actively developed. No new features or bug fixes are expected. Consider alternative approaches for advanced port management.
fix
If you need more robust port reservation, consider using low-level socket APIs or platform-specific solutions.
affects: >=1.0.0
Errors
Common errors & fixes
ImportError: No module named ephemeral_port_reserve
The library is not installed or the import path is incorrect.
fix
Run 'pip install ephemeral-port-reserve' (note hyphens) and import with underscores: 'from ephemeral_port_reserve import reserve'.
OSError: [Errno 98] Address already in use
The reserved port is still in TIME_WAIT from a previous use, or another process is using it.
fix
The library avoids this by using time_wait state, but if it occurs, wait for the TIME_WAIT to expire (typically 2 * MSL) or use a different port. Retry reservation.
Upgrade
Version history
1.1.4latest on PyPI · released Feb 11, 2021
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
ephemeral-port-reserve — pip install ephemeral-port-reserve · libregistry