# Path: azmq/log.py



import asyncio
from functools import wraps
from pyslot import Signal
from .log import logger
    """
    def on_open(self, callback, timeout):
        """
        Initialize a new timeout.

        :param callback: The  callback to execute when the timeout reaches the
            end of its life. May be a coroutine function.
        :param timeout: The maximum time to wait for, in seconds.
        """
        super().on_open()
        self.callback = callback
        self.timeout = timeout
        self.revive_event = asyncio.Event(loop=self.loop)

    async def on_run(self):
        try:
            while True:
                await asyncio.wait_for(
                    self.revive_event.wait(),
                    timeout=self.timeout,
                    loop=self.loop,
                )
                self.revive_event.clear()
        except asyncio.TimeoutError:
            try:
                if asyncio.iscoroutinefunction(self.callback):
                    await self.callback()
                else:
                    self.callback()
            except Exception:

# Path: azmq/log.py



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

    """
    def on_open(self, callback, timeout):
        """
        Initialize a new timeout.

        :param callback: The  callback to execute when the timeout reaches the
            end of its life. May be a coroutine function.
        :param timeout: The maximum time to wait for, in seconds.
        """
        super().on_open()
        self.callback = callback
        self.timeout = timeout
        self.revive_event = asyncio.Event(loop=self.loop)

    async def on_run(self):
        try:
            while True:
                await asyncio.wait_for(
                    self.revive_event.wait(),
                    timeout=self.timeout,
                    loop=self.loop,
                )
                self.revive_event.clear()
        except asyncio.TimeoutError:
            try:
                if asyncio.iscoroutinefunction(self.callback):
                    await self.callback()
                else:
                    self.callback()
            except Exception:

                logger.exception("Error in timeout callback execution.")