# Path: concert/quantities.py

# 
# Path: concert/config.py
# AIODEBUG = 9


import asyncio
import os
import logging
    import IPython
    import PyTango
from concert.quantities import q
from concert.config import AIODEBUG
        from IPython.core.async_helpers import get_asyncio_loop
    async def execute(self, data, num=1024):
        """Execute command and wait for response (coroutine-safe, not thread-safe). Read *num* bytes
        from the socket.
        """
        async with self.lock:
            await self.send(data)
            result = await self.recv(num=num)

        return result


def get_tango_device(uri, peer=None, timeout=10 * q.s):
    """
    Get a Tango device by specifying its *uri*. If *peer* is given change the tango_host specifying
    which database to connect to. Format is host:port as a string. *timeout* sets the device's
    general timeout. It is converted to milliseconds, converted to integer and then the tango
    device's `set_timout_millis` is called with the converted integer value.
    """

    if peer is not None:
        os.environ["TANGO_HOST"] = peer

    executor = None
    if IPython.version_info >= (8, 0):
        ipython_loop = get_asyncio_loop()
        executor = PyTango.asyncio_executor.AsyncioExecutor(loop=ipython_loop)

    device = PyTango.DeviceProxy(
        uri, green_mode=PyTango.GreenMode.Asyncio, asyncio_executor=executor
    )

# Path: concert/quantities.py

# 
# Path: concert/config.py
# AIODEBUG = 9


# Path: concert/networking/base.py
import asyncio
import os
import logging
    import IPython
    import PyTango
from concert.quantities import q
from concert.config import AIODEBUG
        from IPython.core.async_helpers import get_asyncio_loop

    async def execute(self, data, num=1024):
        """Execute command and wait for response (coroutine-safe, not thread-safe). Read *num* bytes
        from the socket.
        """
        async with self.lock:
            await self.send(data)
            result = await self.recv(num=num)

        return result


def get_tango_device(uri, peer=None, timeout=10 * q.s):
    """
    Get a Tango device by specifying its *uri*. If *peer* is given change the tango_host specifying
    which database to connect to. Format is host:port as a string. *timeout* sets the device's
    general timeout. It is converted to milliseconds, converted to integer and then the tango
    device's `set_timout_millis` is called with the converted integer value.
    """

    if peer is not None:
        os.environ["TANGO_HOST"] = peer

    executor = None
    if IPython.version_info >= (8, 0):
        ipython_loop = get_asyncio_loop()
        executor = PyTango.asyncio_executor.AsyncioExecutor(loop=ipython_loop)

    device = PyTango.DeviceProxy(
        uri, green_mode=PyTango.GreenMode.Asyncio, asyncio_executor=executor
    )

    device.set_timeout_millis(int(timeout.to(q.ms).magnitude))