mirror of
https://github.com/GNS3/gns3-server
synced 2025-08-04 21:05:24 +00:00
parent
986ab649d7
commit
5388d43695
@ -33,7 +33,7 @@ log = logging.getLogger()
|
|||||||
class ProjectHandler:
|
class ProjectHandler:
|
||||||
|
|
||||||
# How many clients has subcribe to notifications
|
# How many clients has subcribe to notifications
|
||||||
_notifications_listening = 0
|
_notifications_listening = {}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@Route.get(
|
@Route.get(
|
||||||
@ -153,11 +153,12 @@ class ProjectHandler:
|
|||||||
|
|
||||||
pm = ProjectManager.instance()
|
pm = ProjectManager.instance()
|
||||||
project = pm.get_project(request.match_info["project_id"])
|
project = pm.get_project(request.match_info["project_id"])
|
||||||
if ProjectHandler._notifications_listening <= 1:
|
if ProjectHandler._notifications_listening.setdefault(project.id, 0) <= 1:
|
||||||
yield from project.close()
|
yield from project.close()
|
||||||
pm.remove_project(project.id)
|
pm.remove_project(project.id)
|
||||||
|
del ProjectHandler._notifications_listening[project.id]
|
||||||
else:
|
else:
|
||||||
log.info("Skip project closing, another client is listening for project informations")
|
log.warning("Skip project closing, another client is listening for project informations")
|
||||||
response.set_status(204)
|
response.set_status(204)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -203,7 +204,8 @@ class ProjectHandler:
|
|||||||
|
|
||||||
response.start(request)
|
response.start(request)
|
||||||
queue = project.get_listen_queue()
|
queue = project.get_listen_queue()
|
||||||
ProjectHandler._notifications_listening += 1
|
ProjectHandler._notifications_listening.setdefault(project.id, 0)
|
||||||
|
ProjectHandler._notifications_listening[project.id] += 1
|
||||||
response.write("{\"action\": \"ping\"}\n".encode("utf-8"))
|
response.write("{\"action\": \"ping\"}\n".encode("utf-8"))
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
@ -219,7 +221,8 @@ class ProjectHandler:
|
|||||||
except asyncio.futures.TimeoutError as e:
|
except asyncio.futures.TimeoutError as e:
|
||||||
response.write("{\"action\": \"ping\"}\n".encode("utf-8"))
|
response.write("{\"action\": \"ping\"}\n".encode("utf-8"))
|
||||||
project.stop_listen_queue(queue)
|
project.stop_listen_queue(queue)
|
||||||
ProjectHandler._notifications_listening -= 1
|
if project.id in ProjectHandler._notifications_listening:
|
||||||
|
ProjectHandler._notifications_listening[project.id] -= 1
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@Route.get(
|
@Route.get(
|
||||||
|
Loading…
Reference in New Issue
Block a user