diff --git a/oml/nodes.py b/oml/nodes.py index d2a0519..367b0f9 100644 --- a/oml/nodes.py +++ b/oml/nodes.py @@ -202,29 +202,29 @@ class Node(Thread): def _send_response(self): with db.session(): - u = user.models.User.get_or_create(self.user_id) - if u.peered or u.queued: + u = user.models.User.get(self.user_id) + if u and u.peered or u.queued: if DEBUG_NODES: logger.debug('go online peered=%s queued=%s %s (%s)', u.peered, u.queued, u.id, u.nickname) try: self.online = self.can_connect() - if self.online: - if DEBUG_NODES: - logger.debug('connected to %s', self.url) - if u.queued: - if DEBUG_NODES: - logger.debug('queued peering event pending=%s peered=%s', u.pending, u.peered) - if u.pending == 'sent': - self.peering('requestPeering') - elif u.pending == '' and u.peered: - self.peering('acceptPeering') - else: - #fixme, what about cancel/reject peering here? - self.peering('removePeering') except: if DEBUG_NODES: logger.debug('failed to connect to %s', self.user_id) self.online = False + if self.online: + if DEBUG_NODES: + logger.debug('connected to %s', self.url) + if u.queued: + if DEBUG_NODES: + logger.debug('queued peering event pending=%s peered=%s', u.pending, u.peered) + if u.pending == 'sent': + self.peering('requestPeering') + elif u.pending == '' and u.peered: + self.peering('acceptPeering') + else: + #fixme, what about cancel/reject peering here? + self.peering('removePeering') def trigger_status(self): if self.online is not None: