Skip to content

Commit

Permalink
Add try/except around the n2 node creation (#2053)
Browse files Browse the repository at this point in the history
* Add try/except around the n2 node creation
  • Loading branch information
vEpiphyte authored Jan 21, 2021
1 parent 06bc35e commit 4bbc6e6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion synapse/lib/snap.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,13 @@ async def addNodes(self, nodedefs):
# check for embedded ndef rather than n2iden
if isinstance(n2iden, (list, tuple)):
n2form, n2valu = n2iden
n2node = await self.addNode(n2form, n2valu)
try:
n2node = await self.addNode(n2form, n2valu)
except asyncio.CancelledError: # pragma: no cover TODO: remove once >= py 3.8 only
raise
except:
logger.warning(f'Failed to make n2 edge node for {n2iden}')
continue
n2iden = n2node.iden()
await node.addEdge(verb, n2iden)

Expand Down
4 changes: 3 additions & 1 deletion synapse/tests/test_cortex.py
Original file line number Diff line number Diff line change
Expand Up @@ -3025,7 +3025,8 @@ async def test_feed_syn_nodes(self):
await node1.setData('foo', 'bar')
pack = node1.pack()
pack[1]['nodedata']['foo'] = 'bar'
pack[1]['edges'] = (('refs', ('inet:ipv4', '1.2.3.4')),)
pack[1]['edges'] = (('refs', ('inet:ipv4', '1.2.3.4')),
('newp', ('test:newp', 'newp')))
podes.append(pack)

node2 = (await core0.nodes('[ test:int=2 ] | [ +(refs)> { test:int=1 } ]'))[0]
Expand All @@ -3041,6 +3042,7 @@ async def test_feed_syn_nodes(self):
await core1.addFeedData('syn.nodes', podes)
await self.agenlen(3, core1.eval('test:int'))
self.len(1, await core1.nodes('test:int=1 -(refs)> inet:ipv4 +inet:ipv4=1.2.3.4'))
self.len(0, await core1.nodes('test:int=1 -(newp)> *'))

node1 = (await core1.nodes('test:int=1'))[0]
self.eq('bar', await node1.getData('foo'))
Expand Down

0 comments on commit 4bbc6e6

Please sign in to comment.