Skip to content

Instantly share code, notes, and snippets.

@dbrgn
Created October 30, 2012 09:01
Show Gist options
  • Save dbrgn/3979133 to your computer and use it in GitHub Desktop.
Save dbrgn/3979133 to your computer and use it in GitHub Desktop.
def get_free_port():
s = socket.socket()
s.bind(('', 0))
port = s.getsockname()[1]
s.close()
return port
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment