Skip to content

Commit d28215a

Browse files
committed
Add way to stop bridge from inside
1 parent 99e5c53 commit d28215a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

mautrix/bridge/bridge.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ def _run(self) -> None:
197197
self.log.debug(f"Startup actions complete in {round(end_ts - start_ts, 2)} seconds, "
198198
"now running forever")
199199
self.az.ready = True
200-
self.loop.run_forever()
200+
self._stop_task = self.loop.create_future()
201+
self.loop.run_until_complete(self._stop_task)
202+
self.log.debug("manual_stop() called, stopping...")
201203
except KeyboardInterrupt:
202204
self.log.debug("Interrupt received, stopping...")
203205
except Exception:
@@ -233,3 +235,6 @@ async def stop(self) -> None:
233235
def prepare_shutdown(self) -> None:
234236
"""Lifecycle method that is called right before ``sys.exit(0)``."""
235237
pass
238+
239+
def manual_stop(self) -> None:
240+
self._stop_task.set_result(None)

0 commit comments

Comments
 (0)