You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello! I recently started using aio_statsd to log some telemetry to a datadog agent using DogStatsdClient from a web application backend (python asyncio, using Quart). For the most part it works great but once in a while one worker process will have some kind of issue and lose its connection and I'm trying to figure out what the best way to recover in this scenario is
to start with I'm playing with a subclass like this:
classReconnectingDogStatsdClient(DogStatsdClient):
asyncdef_listen(self):
whileTrue:
# this is nearly a copy of DogStatsdClient._listentry:
whilenotself.connection.is_closed:
value=self._get_by_queue()
ifvalue:
awaitself._real_send(value)
else:
awaitasyncio.sleep(0.05)
ifself.connection.future.done():
awaitself.connection.futureexceptasyncio.CancelledError:
breakexceptExceptionase:
log.error(f"status:{self.is_closed=}{self.connection.is_closed=} error: {e}")
# try to reconnectifself.connection.is_closed:
awaitself.connection.connect()
now it doesn't quite feel right to override _listen like this, but I don't see a cleaner way to implement reconnection that also doesn't drop any (or as few as reasonably possible) messages so I'm now here asking for any advice or guidance on this you might be able to offer
The text was updated successfully, but these errors were encountered:
Hello! I recently started using aio_statsd to log some telemetry to a datadog agent using
DogStatsdClient
from a web application backend (python asyncio, using Quart). For the most part it works great but once in a while one worker process will have some kind of issue and lose its connection and I'm trying to figure out what the best way to recover in this scenario isto start with I'm playing with a subclass like this:
now it doesn't quite feel right to override
_listen
like this, but I don't see a cleaner way to implement reconnection that also doesn't drop any (or as few as reasonably possible) messages so I'm now here asking for any advice or guidance on this you might be able to offerThe text was updated successfully, but these errors were encountered: