Fix "Creating multiple IOU nodes at once assigns the same application id". Fixes #1239.

This commit is contained in:
grossmj 2018-01-15 18:09:05 +07:00
parent 30e8949985
commit e5e2b7a8ac
3 changed files with 28 additions and 23 deletions

View File

@ -1 +0,0 @@
# macos-build-test

View File

@ -1142,6 +1142,7 @@ class IOUVM(BaseNode):
:returns: integer between 1 and 512
"""
if self._application_id is None:
#FIXME: is this necessary? application ID is allocated by controller and should not be None
return self._manager.get_application_id(self.id)
return self._application_id

View File

@ -86,6 +86,7 @@ class Project:
self._show_grid = show_grid
self._show_interface_labels = show_interface_labels
self._loading = False
self._add_node_lock = asyncio.Lock()
# Disallow overwrite of existing project
if project_id is None and path is not None:
@ -438,6 +439,10 @@ class Project:
if node_id in self._nodes:
return self._nodes[node_id]
with (yield from self._add_node_lock):
# wait for a node to be completely created before adding a new one
# this is important otherwise we allocate the same application ID
# when creating multiple IOU node at the same time
if node_type == "iou" and 'application_id' not in kwargs.keys():
kwargs['application_id'] = get_next_application_id(self._nodes.values())