forked from auracaster/bumble_mirror
link: make websockets import lazy
This commit is contained in:
@@ -19,8 +19,6 @@ import logging
|
|||||||
import asyncio
|
import asyncio
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
import websockets
|
|
||||||
|
|
||||||
from bumble.colors import color
|
from bumble.colors import color
|
||||||
from bumble.hci import (
|
from bumble.hci import (
|
||||||
Address,
|
Address,
|
||||||
@@ -220,6 +218,8 @@ class RemoteLink:
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def run_connection(self):
|
async def run_connection(self):
|
||||||
|
import websockets # lazy import
|
||||||
|
|
||||||
# Connect to the relay
|
# Connect to the relay
|
||||||
logger.debug(f'connecting to {self.uri}')
|
logger.debug(f'connecting to {self.uri}')
|
||||||
# pylint: disable-next=no-member
|
# pylint: disable-next=no-member
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from .common import Transport, AsyncPipeSink
|
from .common import Transport, AsyncPipeSink
|
||||||
from ..link import RemoteLink
|
|
||||||
from ..controller import Controller
|
from ..controller import Controller
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
@@ -110,6 +109,8 @@ async def open_transport(name: str) -> Transport:
|
|||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
async def open_transport_or_link(name):
|
async def open_transport_or_link(name):
|
||||||
if name.startswith('link-relay:'):
|
if name.startswith('link-relay:'):
|
||||||
|
from ..link import RemoteLink # lazy import
|
||||||
|
|
||||||
link = RemoteLink(name[11:])
|
link = RemoteLink(name[11:])
|
||||||
await link.wait_until_connected()
|
await link.wait_until_connected()
|
||||||
controller = Controller('remote', link=link)
|
controller = Controller('remote', link=link)
|
||||||
|
|||||||
Reference in New Issue
Block a user