Skip to content

Commit

Permalink
fix(backend): properly handle async run state for generic
Browse files Browse the repository at this point in the history
  • Loading branch information
jourdain committed Oct 5, 2023
1 parent 25e0703 commit 247b046
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion python/src/wslink/backends/generic/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class GenericServer(AbstractWebApp):
def __init__(self, server_config):
AbstractWebApp.__init__(self, server_config)
self._websockets = {}
self._stop_event = asyncio.Event()

if "ws" in server_config:
for route, server_protocol in server_config["ws"].items():
Expand Down Expand Up @@ -111,7 +112,11 @@ async def start(self, port_callback):
if port_callback is not None:
port_callback(self.get_port())

await asyncio.Event().wait()
self._stop_event.clear()
await self._stop_event.wait()

async def stop(self):
self._stop_event.set()


def startWebServer(*args, **kwargs):
Expand Down

0 comments on commit 247b046

Please sign in to comment.