cli (base): Refactor loop handling:
The loop was chosen according to the bridge used, but this is not possible anymore before running it, because there is now an "auto" bridge which falls back from D-Bus to PB. To work around that, the loop has been refactored to be started before knowing which bridge is used, then the bridge-dependent hooks are installed later.
This commit is contained in:
parent
30619f5689
commit
1256e92cec
1 changed files with 135 additions and 102 deletions
|
|
@ -47,7 +47,7 @@ from libervia.backend.tools.common import data_format
|
|||
from libervia.backend.tools.common.ansi import ANSI as A
|
||||
import libervia.cli
|
||||
from libervia.cli.constants import Const as C
|
||||
from libervia.cli.loops import QuitException, get_libervia_cli_loop
|
||||
from libervia.cli.loops import QuitException, LiberviaCLILoop
|
||||
from libervia.frontends.bridge.bridge_frontend import BridgeException
|
||||
from libervia.frontends.tools import aio, misc
|
||||
from libervia.frontends.tools.jid import JID
|
||||
|
|
@ -828,6 +828,8 @@ class LiberviaCli:
|
|||
raise exceptions.InternalError(
|
||||
"Something went wrong while initialising bridge."
|
||||
) from e
|
||||
self.loop.install_hooks(self.bridge_settings.type)
|
||||
|
||||
# we wait on init_pre_script instead of ready_get, so the CLI frontend can be used
|
||||
# in init script.
|
||||
await self.bridge.init_pre_script()
|
||||
|
|
@ -846,10 +848,10 @@ class LiberviaCli:
|
|||
return
|
||||
|
||||
def _run(self, args=None, namespace=None):
|
||||
LiberviaCLILoop = get_libervia_cli_loop(self.bridge_settings.type)
|
||||
self.loop = LiberviaCLILoop()
|
||||
try:
|
||||
self.loop.run(self, args, namespace)
|
||||
self.loop.loop.run_until_complete(self.main(args=args, namespace=namespace))
|
||||
self.loop.run(self)
|
||||
except SystemExit as e:
|
||||
# The loop is stopped, but we execute it one more time to call `a_quit` which
|
||||
# will call any cleaning method including async ones.
|
||||
|
|
|
|||
Loading…
Reference in a new issue