mirror of
https://github.com/GNS3/gns3-server.git
synced 2025-06-22 08:50:09 +00:00
Detect the app is exiting and avoid reconnecting to computes.
This commit is contained in:
@ -21,7 +21,6 @@ import asyncio
|
||||
import async_timeout
|
||||
import socket
|
||||
import json
|
||||
import uuid
|
||||
import sys
|
||||
import io
|
||||
from operator import itemgetter
|
||||
@ -295,6 +294,7 @@ class Compute:
|
||||
"""
|
||||
:param topology_dump: Filter to keep only properties require for saving on disk
|
||||
"""
|
||||
|
||||
if topology_dump:
|
||||
return {
|
||||
"compute_id": self._id,
|
||||
@ -486,7 +486,8 @@ class Compute:
|
||||
log.info(f"Connection closed to compute '{self._id}' WebSocket '{ws_url}'")
|
||||
|
||||
# Try to reconnect after 1 second if server unavailable only if not during tests (otherwise we create a ressources usage bomb)
|
||||
if self.id != "local" and not hasattr(sys, "_called_from_test") or not sys._called_from_test:
|
||||
from gns3server.api.server import app
|
||||
if not app.state.exiting and not hasattr(sys, "_called_from_test") or not sys._called_from_test:
|
||||
log.info(f"Reconnecting to to compute '{self._id}' WebSocket '{ws_url}'")
|
||||
asyncio.get_event_loop().call_later(1, lambda: asyncio.ensure_future(self.connect()))
|
||||
|
||||
|
Reference in New Issue
Block a user