Port allocation cleanup usage reporting
Project description
TooManyPorts
A lightweight Python library for port allocation, monitoring, and management.
Installation
Install via pip:
pip install toomanyports
Usage
from toomanyports import PortManager
pm = PortManager()
Examples
Find a free port
Find a single available port starting from 3000:
port = pm.find(3000, 1)[0]
Find multiple free ports
ports = pm.find(3000, 2)
Kill a process on a specific port
success = pm.kill(8080)
Kill processes on multiple ports
results = pm.kill_all([8080, 8081])
List port usage
Retrieve the process IDs listening on ports 3000 through 3010:
usage = pm.list_usage((3000, 3010))
Obtain a random ephemeral port
random_port = pm.random_port()
Shorthand call
free_port = pm(3000)
Testing
Run the test suite with:
pytest tests_core.py
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file toomanyports-0.1.11.tar.gz.
File metadata
- Download URL: toomanyports-0.1.11.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.13.2 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74815881c9f31ac76dfbd44300d043d898d013fc6cd44a6ac57c2597e7f2d566
|
|
| MD5 |
3a5c4c7c71fbcfb5c5f21da3fca306fd
|
|
| BLAKE2b-256 |
50e3a79f057a0b967142ed326d01153d6c89e6a226efffab99b24a3d46f1de1f
|
File details
Details for the file toomanyports-0.1.11-py3-none-any.whl.
File metadata
- Download URL: toomanyports-0.1.11-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.13.2 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ccfb671fba6cfca44b8e90ffefc08f20add9572149bc54faaed8d54c46adea0
|
|
| MD5 |
4d5137e3a521fecd62b7e239cda171f7
|
|
| BLAKE2b-256 |
63cee33f16e1b91564e6ed0e89007f758059b3495a20bad2bcfd0f3fc93a5943
|