Store socket_info as a dictionary rather than an array

This commit is contained in:
Justin Santa Barbara
2011-03-30 09:04:29 -07:00
parent 6be1c7935e
commit e40fcf9547
2 changed files with 11 additions and 10 deletions

View File

@@ -61,15 +61,16 @@ class Server(object):
def __init__(self, threads=1000):
self.pool = eventlet.GreenPool(threads)
self.ports = []
self.socket_info = {}
def start(self, application, port, host='0.0.0.0', backlog=128):
def start(self, application, port, host='0.0.0.0', key=None, backlog=128):
"""Run a WSGI server with the given application."""
arg0 = sys.argv[0]
logging.audit(_("Starting %(arg0)s on %(host)s:%(port)s") % locals())
socket = eventlet.listen((host, port), backlog=backlog)
self.pool.spawn_n(self._run, application, socket)
self.ports.append(socket.getsockname())
if key:
self.socket_info[key] = socket.getsockname()
def wait(self):
"""Wait until all servers have completed running."""