Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

toomanyports-0.1.11.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

toomanyports-0.1.11-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

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

Hashes for toomanyports-0.1.11.tar.gz
Algorithm Hash digest
SHA256 74815881c9f31ac76dfbd44300d043d898d013fc6cd44a6ac57c2597e7f2d566
MD5 3a5c4c7c71fbcfb5c5f21da3fca306fd
BLAKE2b-256 50e3a79f057a0b967142ed326d01153d6c89e6a226efffab99b24a3d46f1de1f

See more details on using hashes here.

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

Hashes for toomanyports-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 9ccfb671fba6cfca44b8e90ffefc08f20add9572149bc54faaed8d54c46adea0
MD5 4d5137e3a521fecd62b7e239cda171f7
BLAKE2b-256 63cee33f16e1b91564e6ed0e89007f758059b3495a20bad2bcfd0f3fc93a5943

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page