mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-01 04:38:12 +00:00
Remove unnecessary locks.
This commit is contained in:
parent
5b08677537
commit
17d5b3a7bc
@ -58,7 +58,6 @@ class DynamipsHypervisor:
|
|||||||
self._uuid = None
|
self._uuid = None
|
||||||
self._reader = None
|
self._reader = None
|
||||||
self._writer = None
|
self._writer = None
|
||||||
|
|
||||||
self._io_lock = asyncio.Lock()
|
self._io_lock = asyncio.Lock()
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
@ -82,8 +81,7 @@ class DynamipsHypervisor:
|
|||||||
while time.time() - begin < timeout:
|
while time.time() - begin < timeout:
|
||||||
yield from asyncio.sleep(0.01)
|
yield from asyncio.sleep(0.01)
|
||||||
try:
|
try:
|
||||||
with (yield from self._io_lock):
|
self._reader, self._writer = yield from asyncio.open_connection(host, self._port)
|
||||||
self._reader, self._writer = yield from asyncio.open_connection(host, self._port)
|
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
last_exception = e
|
last_exception = e
|
||||||
continue
|
continue
|
||||||
@ -123,9 +121,8 @@ class DynamipsHypervisor:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
yield from self.send("hypervisor close")
|
yield from self.send("hypervisor close")
|
||||||
with (yield from self._io_lock):
|
self._writer.close()
|
||||||
self._writer.close()
|
self._reader, self._writer = None
|
||||||
self._reader, self._writer = None
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def stop(self):
|
def stop(self):
|
||||||
@ -133,18 +130,17 @@ class DynamipsHypervisor:
|
|||||||
Stops this hypervisor (will no longer run).
|
Stops this hypervisor (will no longer run).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
with (yield from self._io_lock):
|
try:
|
||||||
try:
|
# try to properly stop the hypervisor
|
||||||
# try to properly stop the hypervisor
|
yield from self.send("hypervisor stop")
|
||||||
yield from self.send("hypervisor stop")
|
except DynamipsError:
|
||||||
except DynamipsError:
|
pass
|
||||||
pass
|
try:
|
||||||
try:
|
yield from self._writer.drain()
|
||||||
yield from self._writer.drain()
|
self._writer.close()
|
||||||
self._writer.close()
|
except OSError as e:
|
||||||
except OSError as e:
|
log.debug("Stopping hypervisor {}:{} {}".format(self._host, self._port, e))
|
||||||
log.debug("Stopping hypervisor {}:{} {}".format(self._host, self._port, e))
|
self._reader = self._writer = None
|
||||||
self._reader = self._writer = None
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def reset(self):
|
def reset(self):
|
||||||
@ -283,7 +279,7 @@ class DynamipsHypervisor:
|
|||||||
.format(host=self._host, port=self._port, run=self.is_running()))
|
.format(host=self._host, port=self._port, run=self.is_running()))
|
||||||
buf += chunk.decode()
|
buf += chunk.decode()
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
raise DynamipsError("Communication timed out with {host}:{port} :{error}, Dynamips process running: {run}"
|
raise DynamipsError("Lost communication with {host}:{port} :{error}, Dynamips process running: {run}"
|
||||||
.format(host=self._host, port=self._port, error=e, run=self.is_running()))
|
.format(host=self._host, port=self._port, error=e, run=self.is_running()))
|
||||||
|
|
||||||
# If the buffer doesn't end in '\n' then we can't be done
|
# If the buffer doesn't end in '\n' then we can't be done
|
||||||
|
Loading…
Reference in New Issue
Block a user