@@ -4097,7 +4097,7 @@ async def iterNodeDataKeys(self, buid):
4097
4097
async def iterLayerAddPerms (self ):
4098
4098
4099
4099
# nodes & props
4100
- async for byts , abrv in s_coro . pause (self .propabrv .slab .scanByFull (db = self .propabrv .name2abrv )):
4100
+ for idx , ( byts , abrv ) in enumerate (self .propabrv .slab .scanByFull (db = self .propabrv .name2abrv )):
4101
4101
form , prop = s_msgpack .un (byts )
4102
4102
if form is None :
4103
4103
continue
@@ -4108,37 +4108,52 @@ async def iterLayerAddPerms(self):
4108
4108
else :
4109
4109
yield ('node' , 'add' , form )
4110
4110
4111
+ if idx % 1000 == 0 :
4112
+ await asyncio .sleep (0 )
4113
+
4111
4114
# tagprops
4112
- async for byts , abrv in s_coro . pause (self .tagpropabrv .slab .scanByFull (db = self .tagpropabrv .name2abrv )):
4115
+ for idx , ( byts , abrv ) in enumerate (self .tagpropabrv .slab .scanByFull (db = self .tagpropabrv .name2abrv )):
4113
4116
info = s_msgpack .un (byts )
4114
4117
if None in info or len (info ) != 3 :
4115
4118
continue
4116
4119
4117
4120
if self .layrslab .prefexists (abrv , db = self .bytagprop ):
4118
4121
yield ('node' , 'tag' , 'add' , * info [1 ].split ('.' ))
4119
4122
4123
+ if idx % 1000 == 0 :
4124
+ await asyncio .sleep (0 )
4125
+
4120
4126
# nodedata
4121
- async for abrv in s_coro . pause (self .dataslab .scanKeys (db = self .dataname )):
4127
+ for idx , abrv in enumerate (self .dataslab .scanKeys (db = self .dataname )):
4122
4128
name , _ = self .getAbrvProp (abrv )
4123
4129
yield ('node' , 'data' , 'set' , name )
4124
4130
4131
+ if idx % 1000 == 0 :
4132
+ await asyncio .sleep (0 )
4133
+
4125
4134
# edges
4126
- async for verb in s_coro . pause (self .layrslab .scanKeys (db = self .byverb )):
4135
+ for idx , verb in enumerate (self .layrslab .scanKeys (db = self .byverb )):
4127
4136
yield ('node' , 'edge' , 'add' , verb .decode ())
4128
4137
4138
+ if idx % 1000 == 0 :
4139
+ await asyncio .sleep (0 )
4140
+
4129
4141
# tags
4130
4142
# NB: tag perms should be yielded for every leaf on every node in the layer
4131
4143
async with self .core .getSpooledDict () as tags :
4132
4144
4133
4145
# Collect all tag abrvs for all nodes in the layer
4134
- async for lkey , buid in s_coro . pause (self .layrslab .scanByFull (db = self .bytag )):
4146
+ for idx , ( lkey , buid ) in enumerate (self .layrslab .scanByFull (db = self .bytag )):
4135
4147
abrv = lkey [:8 ]
4136
4148
abrvs = list (tags .get (buid , []))
4137
4149
abrvs .append (abrv )
4138
4150
await tags .set (buid , abrvs )
4139
4151
4152
+ if idx % 1000 == 0 :
4153
+ await asyncio .sleep (0 )
4154
+
4140
4155
# Iterate over each node and it's tags
4141
- async for buid , abrvs in s_coro . pause (tags .items ()):
4156
+ for idx , ( buid , abrvs ) in enumerate (tags .items ()):
4142
4157
seen = {}
4143
4158
4144
4159
if len (abrvs ) == 1 :
@@ -4161,6 +4176,9 @@ async def iterLayerAddPerms(self):
4161
4176
if count == 1 :
4162
4177
yield ('node' , 'tag' , 'add' , * key )
4163
4178
4179
+ if idx % 1000 == 0 :
4180
+ await asyncio .sleep (0 )
4181
+
4164
4182
async def iterLayerDelPerms (self ):
4165
4183
async for perm in self .iterLayerAddPerms ():
4166
4184
if perm [:2 ] == ('node' , 'add' ):
0 commit comments