Skip to content

Commit 4b78652

Browse files
authored
Fire an event when a pkg onload completes (SYN-6752) (#3497)
1 parent 1d8f9bb commit 4b78652

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

synapse/cortex.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2728,6 +2728,7 @@ async def _onload():
27282728
raise
27292729
except Exception: # pragma: no cover
27302730
logger.warning(f'onload failed for package: {name}')
2731+
await self.fire('core:pkg:onload:complete', pkg=name)
27312732
self.schedCoro(_onload())
27322733

27332734
async def _dropStormPkg(self, pkgdef):

synapse/tests/test_lib_storm.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,6 +2071,8 @@ async def get(self, name):
20712071
msgs = await core.stormlist(f'pkg.load --ssl-noverify https://127.0.0.1:{port}/api/v1/pkgtest/notok')
20722072
self.stormIsInWarn('pkg.load got JSON error: FooBar', msgs)
20732073

2074+
waiter = core.waiter(2, 'core:pkg:onload:complete')
2075+
20742076
with self.getAsyncLoggerStream('synapse.cortex') as stream:
20752077
msgs = await core.stormlist(f'pkg.load --ssl-noverify https://127.0.0.1:{port}/api/v1/pkgtest/yep')
20762078
self.stormIsInPrint('testload @0.3.0', msgs)
@@ -2085,6 +2087,12 @@ async def get(self, name):
20852087
self.isin("No var with name: newp", buf)
20862088
self.len(1, await core.nodes(f'ps:contact={cont}'))
20872089

2090+
evnts = await waiter.wait(timeout=2)
2091+
self.eq([
2092+
('core:pkg:onload:complete', {'pkg': 'testload'}),
2093+
('core:pkg:onload:complete', {'pkg': 'testload'}),
2094+
], evnts)
2095+
20882096
async def test_storm_tree(self):
20892097

20902098
async with self.getTestCore() as core:

0 commit comments

Comments
 (0)