Fix Pypo giving up too early on attempting to receive schedule

This commit is contained in:
Martin Konecny 2013-01-25 12:11:50 -05:00
parent a14d99d87b
commit 21a04803e5
1 changed files with 13 additions and 3 deletions

View File

@ -217,7 +217,7 @@ class PypoFetch(Thread):
self.set_bootstrap_variables()
#get the most up to date schedule, which will #initiate the process
#of making sure Liquidsoap is playing the schedule
self.manual_schedule_fetch()
self.persistent_manual_schedule_fetch(max_attempts=5)
except Exception, e:
self.logger.error(str(e))
@ -488,10 +488,20 @@ class PypoFetch(Thread):
self.process_schedule(self.schedule_data)
return success
def persistent_manual_schedule_fetch(self, max_attempts=1):
success = False
num_attempts = 0
while not success and num_attempts < max_attempts:
success = self.manual_schedule_fetch()
num_attempts += 1
return success
def main(self):
# Bootstrap: since we are just starting up, we need to grab the
# most recent schedule. After that we can just wait for updates.
success = self.manual_schedule_fetch()
success = self.persistent_manual_schedule_fetch(max_attempts=5)
if success:
self.logger.info("Bootstrap schedule received: %s", self.schedule_data)
self.set_bootstrap_variables()
@ -519,7 +529,7 @@ class PypoFetch(Thread):
self.handle_message(message)
except Empty, e:
self.logger.info("Queue timeout. Fetching schedule manually")
self.manual_schedule_fetch()
self.persistent_manual_schedule_fetch(max_attempts=5)
except Exception, e:
import traceback
top = traceback.format_exc()