Raise exception if we try to reserve an already reserve port

This commit is contained in:
Julien Duponchelle committed 2015-01-20 20:09:20 +01:00
1 parent fa57485f11
commit f2289874af
2 files changed
+33 -5

No files matched your search

+6 -5
View File
@@ -18,6 +18,7 @@
import socket
import ipaddress
import asyncio
from aiohttp.web import HTTPConflict
class PortManager:
@@ -146,10 +147,10 @@ class PortManager:
else:
continue
raise Exception("Could not find a free port between {} and {} on host {}, last exception: {}".format(start_port,
end_port,
host,
last_exception))
raise HTTPConflict(reason="Could not find a free port between {} and {} on host {}, last exception: {}".format(start_port,
end_port,
host,
last_exception))
def get_free_console_port(self):
"""
@@ -173,7 +174,7 @@ class PortManager:
"""
if port in self._used_tcp_ports:
raise Exception("TCP port already {} in use on host".format(port, self._host))
raise HTTPConflict(reason="TCP port already {} in use on host".format(port, self._console_host))
self._used_tcp_ports.add(port)
def release_console_port(self, port):