# Path: azmq/log.py



import asyncio
from functools import wraps
from pyslot import Signal
from .log import logger
    Base class for objects that keep a reference to an event loop.
    """
    def __init__(self, loop=None):
        self.loop = loop or asyncio.get_event_loop()


def cancel_on_closing(func):
    """
    Automatically cancels a function or coroutine when the defining instance
    gets closed.

    :param func: The function to cancel on closing.
    :returns: A decorated function or coroutine.
    """
    @wraps(func)
    async def wrapper(self, *args, **kwargs):
        return await self.await_until_closing(func(self, *args, **kwargs))

    return wrapper


class ClosableAsyncObject(AsyncObject):
    """
    Base class for objects that can be asynchronously closed and awaited.
    """
    def __init__(self, *args, loop=None, **kwargs):
        super().__init__(loop=loop)
        self._closed_future = asyncio.Future(loop=self.loop)
        self._closing = asyncio.Event(loop=self.loop)
        self.on_closed = Signal()

# Path: azmq/log.py



# Path: azmq/common.py
import asyncio
from functools import wraps
from pyslot import Signal
from .log import logger

    Base class for objects that keep a reference to an event loop.
    """
    def __init__(self, loop=None):
        self.loop = loop or asyncio.get_event_loop()


def cancel_on_closing(func):
    """
    Automatically cancels a function or coroutine when the defining instance
    gets closed.

    :param func: The function to cancel on closing.
    :returns: A decorated function or coroutine.
    """
    @wraps(func)
    async def wrapper(self, *args, **kwargs):
        return await self.await_until_closing(func(self, *args, **kwargs))

    return wrapper


class ClosableAsyncObject(AsyncObject):
    """
    Base class for objects that can be asynchronously closed and awaited.
    """
    def __init__(self, *args, loop=None, **kwargs):
        super().__init__(loop=loop)
        self._closed_future = asyncio.Future(loop=self.loop)
        self._closing = asyncio.Event(loop=self.loop)
        self.on_closed = Signal()

        logger.debug("%s[%s] opened.", self.__class__.__name__, id(self))