Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle more socket exceptions #349

Merged
merged 4 commits into from
Feb 5, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion datadog/dogstatsd/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,12 @@ def _send_to_server(self, packet):
except socket.timeout:
# dogstatsd is overflowing, drop the packets (mimicks the UDP behaviour)
return
except socket.error:
except (socket.error, socket.herror, socket.gaierror) as se:
log.info("Error submitting packet, dropping the packet and closing the socket")
dabcoder marked this conversation as resolved.
Show resolved Hide resolved
self.close_socket()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be closing the socket in the second except clause as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, # If set, use socket directly, would the last exception cover the case of not using the socket and thus not needing to close it? Or am I on the wrong track there?

except Exception as e:
log.info("Unexpected error: ", e)
dabcoder marked this conversation as resolved.
Show resolved Hide resolved
return

def _send_to_buffer(self, packet):
self.buffer.append(packet)
Expand Down