comparison lib/patchsource.py @ 429:fcd2c026f51e

exportStats for sending scales data to influxdb Ignore-this: 715ff40fed97559efa37edf0efa58220
author drewp@bigasterisk.com
date Sun, 07 Apr 2019 03:56:17 -0700
parents 7716b1810d6c
children 124c921ad52d
comparison
equal deleted inserted replaced
428:d6a6076fce6e 429:fcd2c026f51e
107 at init time to not miss any patches. You'll get another 107 at init time to not miss any patches. You'll get another
108 fullGraph=True patch if we have to reconnect. 108 fullGraph=True patch if we have to reconnect.
109 109
110 todo: generate connection stmts in here 110 todo: generate connection stmts in here
111 """ 111 """
112 def __init__(self, url, listener): 112 def __init__(self, url, listener, reconnectSecs=60):
113 self.url = url 113 self.url = url
114 self._stopped = False 114 self._stopped = False
115 self._listener = listener 115 self._listener = listener
116 self.reconnectSecs = reconnectSecs
116 self._reconnect() 117 self._reconnect()
117 118
118 def _reconnect(self): 119 def _reconnect(self):
119 if self._stopped: 120 if self._stopped:
120 return 121 return
134 def stop(self): 135 def stop(self):
135 self._stopped = True 136 self._stopped = True
136 self._ps.stop() 137 self._ps.stop()
137 138
138 def _onConnectionFailed(self, arg): 139 def _onConnectionFailed(self, arg):
139 reactor.callLater(60, self._reconnect) 140 reactor.callLater(self.reconnectSecs, self._reconnect)
140 141
141 def _onConnectionLost(self, arg): 142 def _onConnectionLost(self, arg):
142 reactor.callLater(60, self._reconnect) 143 reactor.callLater(self.reconnectSecs, self._reconnect)
143 144