From 14f426afd49dd2590272e5f158570392b8d07e9f Mon Sep 17 00:00:00 2001 From: j Date: Wed, 3 Sep 2014 00:33:42 +0200 Subject: [PATCH] only handle exception if still active --- oml/localnodes.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/oml/localnodes.py b/oml/localnodes.py index 1bcff99..3140b14 100644 --- a/oml/localnodes.py +++ b/oml/localnodes.py @@ -85,13 +85,15 @@ class LocalNodesBase(Thread): if data: self.update_node(data) except socket.timeout: - now = time.mktime(time.localtime()) - if now - last > 60: - last = now - thread.start_new_thread(self.send, ()) + if self._active: + now = time.mktime(time.localtime()) + if now - last > 60: + last = now + thread.start_new_thread(self.send, ()) except: - logger.debug('receive failed. restart later', exc_info=1) - time.sleep(10) + if self._active: + logger.debug('receive failed. restart later', exc_info=1) + time.sleep(10) def verify(self, data): try: