Mercurial > code > home > repos > homeauto
comparison lib/patchsource.py @ 1232:b50a13ef20ba
exportStats for sending scales data to influxdb
Ignore-this: 715ff40fed97559efa37edf0efa58220
darcs-hash:bcdd9713c4bf9c2ebe732ae1d30edc44f1be704f
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Sun, 07 Apr 2019 03:56:17 -0700 |
parents | ee168d55524a |
children | 24c004aac998 |
comparison
equal
deleted
inserted
replaced
1231:996a00d72979 | 1232:b50a13ef20ba |
---|---|
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 |