Skip to content

Commit

Permalink
Call plugin unload function after stopping event loop (#539)
Browse files Browse the repository at this point in the history
This can prevent race conditions where unload is clearing data but main is still working with it
  • Loading branch information
Jan200101 authored Dec 16, 2023
1 parent 3489fd7 commit 39f4f28
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion backend/src/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ async def _on_new_message(self, message : str) -> str|None:

if "stop" in data:
self.log.info("Calling Loader unload function.")
await self._unload()
get_event_loop().stop()
while get_event_loop().is_running():
await sleep(0)
get_event_loop().close()
await self._unload()
raise Exception("Closing message listener")

# TODO there is definitely a better way to type this
Expand Down

0 comments on commit 39f4f28

Please sign in to comment.