From 7d591b022888cf2bea925ff59a87471e43d9732c Mon Sep 17 00:00:00 2001 From: grossmj Date: Thu, 14 Mar 2019 15:15:27 +0700 Subject: [PATCH] Fix issue when loading and quickly closing a project and opening it again. Fixes #1501. --- gns3server/controller/project.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gns3server/controller/project.py b/gns3server/controller/project.py index 6833a0ea..34ace5ff 100644 --- a/gns3server/controller/project.py +++ b/gns3server/controller/project.py @@ -94,6 +94,7 @@ class Project: self._supplier = supplier self._loading = False + self._closing = False # Disallow overwrite of existing project if project_id is None and path is not None: @@ -743,12 +744,14 @@ class Project: del self._snapshots[snapshot.id] os.remove(snapshot.path) + @locking async def close(self, ignore_notification=False): - if self._status == "closed": + if self._status == "closed" or self._closing: return if self._loading: log.warning("Closing project '{}' ignored because it is being loaded".format(self.name)) return + self._closing = True await self.stop_all() for compute in list(self._project_created_on_compute): try: @@ -761,6 +764,7 @@ class Project: if not ignore_notification: self.emit_notification("project.closed", self.__json__()) self.reset() + self._closing = False def _clean_pictures(self): """ @@ -843,6 +847,10 @@ class Project: """ Load topology elements """ + + if self._closing is True: + raise aiohttp.web.HTTPConflict(text="Project is closing, please try again in a few seconds...") + if self._status == "opened": return