diff options
Diffstat (limited to '')
| -rw-r--r-- | bot/async_stats.py | 41 | 
1 files changed, 0 insertions, 41 deletions
| diff --git a/bot/async_stats.py b/bot/async_stats.py deleted file mode 100644 index 2af832e5b..000000000 --- a/bot/async_stats.py +++ /dev/null @@ -1,41 +0,0 @@ -import asyncio -import socket - -from statsd.client.base import StatsClientBase - -from bot.utils import scheduling - - -class AsyncStatsClient(StatsClientBase): -    """An async transport method for statsd communication.""" - -    def __init__( -        self, -        loop: asyncio.AbstractEventLoop, -        host: str = 'localhost', -        port: int = 8125, -        prefix: str = None -    ): -        """Create a new client.""" -        family, _, _, _, addr = socket.getaddrinfo( -            host, port, socket.AF_INET, socket.SOCK_DGRAM)[0] -        self._addr = addr -        self._prefix = prefix -        self._loop = loop -        self._transport = None - -    async def create_socket(self) -> None: -        """Use the loop.create_datagram_endpoint method to create a socket.""" -        self._transport, _ = await self._loop.create_datagram_endpoint( -            asyncio.DatagramProtocol, -            family=socket.AF_INET, -            remote_addr=self._addr -        ) - -    def _send(self, data: str) -> None: -        """Start an async task to send data to statsd.""" -        scheduling.create_task(self._async_send(data), event_loop=self._loop) - -    async def _async_send(self, data: str) -> None: -        """Send data to the statsd server using the async transport.""" -        self._transport.sendto(data.encode('ascii'), self._addr) | 
