end peering in task thread if we get a 403

This commit is contained in:
j 2016-01-14 17:56:01 +05:30
parent 78e48e65bd
commit 753724a23c

View file

@ -173,13 +173,13 @@ class Node(Thread):
r = self._opener.open(url, data=content)
except urllib.error.HTTPError as e:
if e.code == 403:
logger.debug('REMOTE ENDED PEERING')
with db.session():
u = self.user
if u.peered:
u.update_peering(False)
logger.debug('403: %s (%s)', url, self.user_id)
self._running = False
if state.tasks:
state.tasks.queue('peering', (self.user_id, False))
del self._nodes[self.user_id]
self.online = False
return
return None
logger.debug('urllib2.HTTPError %s %s', e, e.code)
self.online = False
return None