From ed275e4ec5c41f1e32df5d129f39e47b6e2af9c0 Mon Sep 17 00:00:00 2001 From: grossmj Date: Sun, 14 Jan 2018 19:06:35 +0700 Subject: [PATCH] Fix UnboundLocalError: local variable 'node' referenced before assignment. Fixes #1256. --- gns3server/compute/base_manager.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gns3server/compute/base_manager.py b/gns3server/compute/base_manager.py index 59e9c90a..4dd8ae36 100644 --- a/gns3server/compute/base_manager.py +++ b/gns3server/compute/base_manager.py @@ -335,11 +335,14 @@ class BaseManager: :returns: Node instance """ + node = None try: - node = yield from self.close_node(node_id) + node = self.get_node(node_id) + yield from self.close_node(node_id) finally: - node.project.emit("node.deleted", node) - yield from node.project.remove_node(node) + if node: + node.project.emit("node.deleted", node) + yield from node.project.remove_node(node) if node.id in self._nodes: del self._nodes[node.id] return node