Python version to get unused ports

Python version of the one implemented in Ruby. Needed again for server testing ... prz

def unused_port():
    import socket

    sock = socket.socket()
    sock.bind(("localhost", 0))
    port = sock.getsockname()[1]
    sock.close()
    return port

Recommended Posts

Python version to get unused ports
How to get the Python version
Introduction to Python (Python version APG4b)
How to change Python version
Link to get started with python
How to get started with Python
[AWS SAM] Introduction to Python version
How to get a stacktrace in python
Updated to Python 2.7.9
[Yahoo! Weather Replacement Version] How to get weather information with LINE Notify + Python
PYTHON2.7 64bit version
"Backport" to python 2
[2020 version] How to install Python3 on AWS EC2
Python for super beginners Python for super beginners # Easy to get angry
Let's understand how to pass arguments (Python version)
[Bash] Use here-documents to get python power from bash
I tried to get CloudWatch data with Python
How to specify TLS version in python requests
Get pointers to struct members in Python ctypes
[Improved version] Script to monitor CPU with Python
Get information about videos uploaded to YouTube [Python]
How to get the files in the [Python] folder
What to do to get google spreadsheet in python
A layman wants to get started with Python
Python script to get note information with REAPER
Use os.getenv to get environment variables in Python
[Python] Get environment variables
How to get the variable name itself in python
[First API] Try to get Qiita articles with Python
How to get the number of digits in Python
How to install Python
Changes from Python 3.0 to Python 3.5
Get the GNOME version
Changes from Python 2 to Python 3.0
[Python] Get Qiita trends
How to auto-submit Microsoft Forms using python (Mac version)
Rewrite Python2 code to Python3 (2to3)
python decorator to retry
Introduction to Python language
I tried to get started with blender python script_Part 02
Introduction to OpenCV (python)-(2)
Note to daemonize python
[Python3] Get date diff
Get date in Python
Introducing Python 2.7 to CentOS 6.6
How to get mouse wheel verdict with Python curses
Get date with python
Connect python to mysql
[Python MinMaxScaler] Normalize to 0 ~ 1
update django version 1.11.1 to 2.2
Python version switching (pyenv)
[Python] I tried to get Json of squid ring 2
Check version with python
[Python] Get used to Keras while implementing Reinforcement Learning (DQN)
Get only the Python version (such as 2.7.5) on the CentOS 7 shell
[Python] I want to get a common set between numpy
Get the package version to register with PyPI from Git
Developed a library to get Kindle collection list in Python
I tried "How to get a method decorated in Python"
How to get the last (last) value in a list in Python
How to get a list of built-in exceptions in python