Created
October 30, 2012 09:01
-
-
Save dbrgn/3979133 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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