Commit 18b3658b authored by Arno Töll's avatar Arno Töll
Browse files

Do not crash if the server closes the connection after the first iteration

Handle reconnects softly
parent 5cba04b7
......@@ -100,6 +100,7 @@ class RemoveOldUploads(BaseCronjob):
self.log.debug("Processed all messages up to #%s on %s" % (list_name.value, list_name.code))
meta.session.merge(list_name)
meta.session.commit()
self.mailer.disconnect_from_server()
def _remove_old_packages(self):
now = datetime.datetime.now()
......
......@@ -140,8 +140,13 @@ class Email(object):
(_, count, first, last, _) = self.nntp.group(list_name)
log.debug("Fetching messages %s to %s on %s" % (changed_since, last, list_name))
except nntplib.NNTPError as e:
self.established = False
log.error("Connecting to NNTP server %s failed: %s" % (pylons.config['debexpo.nntp_server'], str(e)))
return
except EOFError:
self.established = False
log.error("NNTP server %s closed connection" % (pylons.config['debexpo.nntp_server']))
return
try:
(_, messages) = self.nntp.xover(str(changed_since), str(last))
......@@ -168,11 +173,13 @@ class Email(object):
def disconnect_from_server(self):
self.nntp.quit()
self.established = False
def connection_established(self):
if not self.established:
self.connect_to_server()
if not self.established:
log.debug("Connection to NNTP server not established");
return False
return self.established
return True
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment