pystatsd icon indicating copy to clipboard operation
pystatsd copied to clipboard

Fix/130 ignore socket errors

Open luismedel opened this issue 1 year ago • 1 comments

This PR adds a way to ignore the dreaded socket.gaierror error when initializing the UDP client and a server is missing.

  • Fixes https://github.com/jsocol/pystatsd/issues/130
  • (Hopefully) fixes https://github.com/jsocol/pystatsd/issues/125

Details

The new constructor signature is:

StatsClient(host='localhost', port=8125, prefix=None, maxudpsize=512, ignore_socket_errors=False)

To complement this flag, I added the is_ready property and the reset() method to clients.

On the UDP client:

  • By default, the client will work as usual. When passing ignore_socket_errors=True, errors during the socket initialization will be ignored.
  • The is_ready property will reflect the state after the initialization.
  • In order to be able to recover from a failed initialization you can use the reset() method.

On streaming clients:

  • They will work as usual (won't ignore errors)
  • is_ready reflects the current status of the inner socket.
  • reset() calls reconnect() under the hood.

Extra

I added a quick Travis detection to skip the tests dynamically.

luismedel avatar Dec 04 '24 15:12 luismedel

Hi @jsocol, I've been waiting for your review on this PR and wanted to check if there's any feedback or changes needed to move it forward. I understand there may be other priorities, but if you need any clarification or additional information, I’d be happy to provide it :)

luismedel avatar Mar 20 '25 10:03 luismedel

Closing this. It seems the repo is unattended.

luismedel avatar Apr 14 '25 12:04 luismedel