Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(399)

Unified Diff: juju/lib/port.py

Issue 7231079: Increase zk session and ping times.
Patch Set: Increase zk session and ping times. Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « juju/environment/tests/test_config.py ('k') | juju/lib/tests/test_port.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: juju/lib/port.py
=== added file 'juju/lib/port.py'
--- juju/lib/port.py 1970-01-01 00:00:00 +0000
+++ juju/lib/port.py 2013-01-31 18:38:30 +0000
@@ -0,0 +1,13 @@
+import socket
+
+
+def get_open_port(host=""):
+ """Get an open port on the machine.
+ """
+ temp_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ temp_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+ temp_sock.bind((host, 0))
+ port = temp_sock.getsockname()[1]
+ temp_sock.close()
+ del temp_sock
+ return port
« no previous file with comments | « juju/environment/tests/test_config.py ('k') | juju/lib/tests/test_port.py » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b