diff options
author | Austin S. Hemmelgarn <ahferroin7@gmail.com> | 2019-07-30 16:21:39 -0400 |
---|---|---|
committer | Ilya Mashchenko <ilya@netdata.cloud> | 2019-07-30 23:21:39 +0300 |
commit | 63114bceddd8ee6916f0c8e5c642a579c2dfc1ac (patch) | |
tree | cca4d1e31a46004e82deb52784344edf1628383f /collectors/python.d.plugin/python_modules | |
parent | b56f03cb710a5f5a714356e1853693dbe62751e0 (diff) |
Handle disconnected sockets in unbound collector. (#6561)
* Handle disconnected sockets in unbound collector.
This adds an explicit check for the case of a socket that's already
disconnected and skips logging an error message. The conditionn
technically is an error, but it's one that we can recover from trivially
by just doing nothing in this case (we were trying to disconnect the
scoket anyway, so if it's already disconnected, we don't need to change
anything).
This uses Python's `errno` module so that we can detect this situation
in a system-agnostic manner.
Fixes #6434
Diffstat (limited to 'collectors/python.d.plugin/python_modules')
-rw-r--r-- | collectors/python.d.plugin/python_modules/bases/FrameworkServices/SocketService.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/collectors/python.d.plugin/python_modules/bases/FrameworkServices/SocketService.py b/collectors/python.d.plugin/python_modules/bases/FrameworkServices/SocketService.py index 27519b76af..3b94fcdf2f 100644 --- a/collectors/python.d.plugin/python_modules/bases/FrameworkServices/SocketService.py +++ b/collectors/python.d.plugin/python_modules/bases/FrameworkServices/SocketService.py @@ -4,6 +4,7 @@ # Author: Ilya Mashchenko (ilyam8) # SPDX-License-Identifier: GPL-3.0-or-later +import errno import socket try: @@ -181,7 +182,8 @@ class SocketService(SimpleService): self._sock.shutdown(2) # 0 - read, 1 - write, 2 - all self._sock.close() except Exception as error: - self.error(error) + if not (hasattr(error, 'errno') and error.errno == errno.ENOTCONN): + self.error(error) self._sock = None def _send(self, request=None): |