Skip to content

Commit

Permalink
syncIndexEvents, yield more often, make unit test less picky
Browse files Browse the repository at this point in the history
  • Loading branch information
jnwatson committed Dec 24, 2020
1 parent bf81234 commit bca89d8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion synapse/lib/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2689,10 +2689,11 @@ async def syncIndexEvents(self, offs, matchdef, wait=True):

yield (curoff, (buid, form, etyp, vals, meta))

await asyncio.sleep(0)

count += 1
if count % 1000 == 0:
yield (curoff, (None, None, EDIT_PROGRESS, (), ()))
await asyncio.sleep(0)

async def makeSplices(self, offs, nodeedits, meta, reverse=False):
'''
Expand Down
6 changes: 3 additions & 3 deletions synapse/tests/test_cortex.py
Original file line number Diff line number Diff line change
Expand Up @@ -4968,15 +4968,15 @@ async def test_cortex_syncindexevents(self):
self.eq(expectadd, item4)

# Make sure progress every 1000 layer log entries works
await core.nodes('[inet:ipv4=192.168.1/22]')
await core.nodes('[inet:ipv4=192.168.1/20]')

offsdict = {baselayr.iden: baseoffs + 1, layriden: baseoffs + 1}

items = await alist(proxy.syncIndexEvents(mdef, offsdict=offsdict, wait=False))

expect = (baseoffs + 5 + 1000, baselayr.iden, s_cortex.SYNC_NODEEDIT,
expect = (9999, baselayr.iden, s_cortex.SYNC_NODEEDIT,
(None, None, s_layer.EDIT_PROGRESS, (), ()))
self.eq(expect, items[1])
self.eq(expect[1:], items[1][1:])

# Make sure that genr wakes up if a new layer occurs after it is already waiting
offs = await core.getNexsIndx()
Expand Down

0 comments on commit bca89d8

Please sign in to comment.