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

syncIndexEvents, yield more often, make unit test less picky #2025

Merged
merged 1 commit into from
Dec 24, 2020
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
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