Fix IOU closing

This commit is contained in:
Julien Duponchelle 2015-02-16 17:40:13 +01:00
parent 15f89776d3
commit 018e3c1451
3 changed files with 11 additions and 7 deletions

View File

@ -110,8 +110,10 @@ class IOUVM(BaseVM):
else:
self._console = self._manager.port_manager.get_free_console_port()
@asyncio.coroutine
def close(self):
yield from self.stop()
if self._console:
self._manager.port_manager.release_console_port(self._console)
self._console = None
@ -498,14 +500,14 @@ class IOUVM(BaseVM):
Stops the IOU process.
"""
# stop console support
if self._ioucon_thread:
self._ioucon_thread_stop_event.set()
if self._ioucon_thread.is_alive():
self._ioucon_thread.join(timeout=3.0) # wait for the thread to free the console port
self._ioucon_thread = None
if self.is_running():
# stop console support
if self._ioucon_thread:
self._ioucon_thread_stop_event.set()
if self._ioucon_thread.is_alive():
self._ioucon_thread.join(timeout=3.0) # wait for the thread to free the console port
self._ioucon_thread = None
self._terminate_process_iou()
try:
yield from asyncio.wait_for(self._iou_process.wait(), timeout=3)

View File

@ -357,6 +357,7 @@ class TelnetServer(Console):
sock_fd.listen(socket.SOMAXCONN)
self.sock_fd = sock_fd
log.info("Telnet server ready for connections on {}:{}".format(self.addr, self.port))
log.info(self.stop_event.is_set())
return self

View File

@ -73,6 +73,7 @@ class VPCSVM(BaseVM):
else:
self._console = self._manager.port_manager.get_free_console_port()
@asyncio.coroutine
def close(self):
self._terminate_process()