Skip to content

Commit

Permalink
Call plugin unload function after stopping event loop
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 committed Sep 13, 2023
1 parent 22d5795 commit be5fed0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion backend/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,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")

d = {"res": None, "success": True}
Expand Down

0 comments on commit be5fed0

Please sign in to comment.