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

[dogstatsd] sock.setblocking(0) for UDP socket #590

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion datadog/dogstatsd/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,12 @@ def get_socket(self):
if not self.socket:
if self.socket_path is not None:
sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
sock.connect(self.socket_path)
sock.setblocking(0)
sock.connect(self.socket_path)
self.socket = sock
else:
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setblocking(0)
Copy link
Contributor

Choose a reason for hiding this comment

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

The order is different compared to the block above, where the blocking is set after connect.
I think your order is fine here, I'm more worried about the one above. But they should probably not be different?

Copy link
Contributor Author

@prognant prognant Jul 15, 2020

Choose a reason for hiding this comment

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

Indeed, I harmonised both cases, I did some test to ensure it does not break anything.

sock.connect((self.host, self.port))
self.socket = sock

Expand Down