Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add try/except around the n2 node creation #2053

Merged
merged 2 commits into from
Jan 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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