# HG changeset patch # User drewp # Date 1460618218 25200 # Node ID d0ca77a3faf44edfe2a66571b9a9a960b51c1ba3 # Parent 32bbce76134e907118a1f3a10a8e6429b79b5752 rewrite oneShotPost to ease debugging. add try-block around polling Ignore-this: b7eef1b0b66fe0ba5d2c269bd1e5e37f darcs-hash:2756095383b97972bfc56217654d9048c6d2eb86 diff -r 32bbce76134e -r d0ca77a3faf4 service/piNode/piNode.py --- a/service/piNode/piNode.py Thu Apr 14 00:16:27 2016 -0700 +++ b/service/piNode/piNode.py Thu Apr 14 00:16:58 2016 -0700 @@ -82,6 +82,12 @@ task.LoopingCall(self._poll).start(.05) def _poll(self): + try: + self._pollMaybeError() + except Exception: + log.exception("During poll:") + + def _pollMaybeError(self): for i in self._devs: now = time.time() if (hasattr(i, 'pollPeriod') and @@ -115,11 +121,17 @@ def _sendOneshot(self, oneshot): body = (' '.join('%s %s %s .' % (s.n3(), p.n3(), o.n3()) for s,p,o in oneshot)).encode('utf8') - bang6 = 'fcb8:4119:fb46:96f8:8b07:1260:0f50:fcfa' - fetch(method='POST', - url='http://[%s]:9071/oneShot' % bang6, - headers={'Content-Type': ['text/n3']}, postdata=body, - timeout=5) + bang = '[fcb8:4119:fb46:96f8:8b07:1260:0f50:fcfa]' + url = 'http://%s:9071/oneShot' % bang + d = fetch(method='POST', + url=url, + headers={'Content-Type': ['text/n3']}, + postdata=body, + timeout=5) + def err(e): + log.info('oneshot post to %r failed: %s', + url, e.getErrorMessage()) + d.addErrback(err) def _exportToGraphite(self): # note this is writing way too often- graphite is storing at a lower res