@cryptotaxi247 / netdata-1 / commits / dd7ec27f5

Update BOINC plugin reconnect handling.

This simplifies the code a bit. THe `reconnect()` method is being explicitly kept for clarity reasons, and includes a comment that a disconnect is not mandatory when trying to reconnect.

Austin S. Hemmelgarn committed Jun 5, 2018 at 10:47 UTC dd7ec27f5c476d6b23a703e4a313f3dfb63c1b32
1 file changed +7 -10
python.d/boinc.chart.py
+7 -10
@@ -124,22 +124,19 @@ class Service(SimpleService):
124 if platform.system() != 'Linux':
125 self.error('Only supported on Linux.')
126 return False
127 - self.connect()
128 - self.alive = self.client.connected and self.client.authorized:
129 - return self.alive
127 + return self.connect()
128
129 def connect(self):
130 self.client.connect()
133 -
134 - def reconnect(self):
135 - try:
136 - self.client.disconnect()
137 - except socket.error:
138 - pass
139 - self.client.connect()
131 self.alive = self.client.connected and self.client.authorized:
132 return self.alive
133
134 + def reconnect(self):
135 + # The client class itself actually disconnects existing
136 + # connections when it is told to connect, so we don't need to
137 + # explicitly disconnect when we're just trying to reconnect.
138 + return self.connect()
139 +
140 def is_alive(self):
141 if (not self.alive) or \
142 self.client.rpc.sock.getsockopt(socket.IPPROTO_TCP, socket.TCP_INFO, 0) != 1: