Skip to main content

Get an available port. Checks first for preferred port in case its available, if not returns random.

Project description

get-port

Open Source Love license Last Commit PyPI PyPI - Python Version PRs Welcome

Get an available port. Checks first for preferred port in case its available, if not returns random. Python implementation of the get-port idea by @sindresorhus.

Installation.

Available via PyPI.

pip install get-port

Usage.

Available in terminal:

get-port [preferred-port-optional]

Usage in code:

# Gets the actual port. Send preferred_port to pick if available.
from get_port import get_port
port = get_port(preferred_port)

# Check if port is available. Returns tuple: (Boolean, Dict)
from get_port import port_available
is_available = port_available(your_port)

# Find random free port. Returns tuple: (Port, Dict)
from get_port import find_free_port
port = find_free_port()

License

MIT.

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

get-port-0.0.5.tar.gz (3.7 kB view hashes)

Uploaded Source

Supported by

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