CC-3342: Pypo: if a user doesn't update anything on calendar for 24 hrs, it could cause a problem.
-fixed
This commit is contained in:
parent
1677bc6816
commit
d5a8f63d36
|
@ -14,6 +14,7 @@ from threading import Thread
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
from Queue import Empty
|
||||||
import filecmp
|
import filecmp
|
||||||
|
|
||||||
# For RabbitMQ
|
# For RabbitMQ
|
||||||
|
@ -494,24 +495,47 @@ class PypoFetch(Thread):
|
||||||
logger.error("Error connecting to RabbitMQ Server. Trying again in few seconds")
|
logger.error("Error connecting to RabbitMQ Server. Trying again in few seconds")
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|
||||||
loops = 1
|
loops = 1
|
||||||
while True:
|
while True:
|
||||||
logger.info("Loop #%s", loops)
|
logger.info("Loop #%s", loops)
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
message = self.simple_queue.get(block=True)
|
"""
|
||||||
|
our simple_queue.get() requires a timeout, in which case we
|
||||||
|
fetch the Airtime schedule manually. It is important to fetch
|
||||||
|
the schedule periodically because if we didn't, we would only
|
||||||
|
get schedule updates via RabbitMq if the user was constantly
|
||||||
|
using the Airtime interface.
|
||||||
|
|
||||||
|
If the user is not using the interface, RabbitMq messages are not
|
||||||
|
sent, and we will have very stale (or non-existent!) data about the
|
||||||
|
schedule.
|
||||||
|
|
||||||
|
Currently we are checking every 3600 seconds (1 hour)
|
||||||
|
"""
|
||||||
|
message = self.simple_queue.get(block=True, timeout=3600)
|
||||||
self.handle_message(message.payload)
|
self.handle_message(message.payload)
|
||||||
# ACK the message to take it off the queue
|
# ACK the message to take it off the queue
|
||||||
message.ack()
|
message.ack()
|
||||||
|
except Empty, e:
|
||||||
|
"""
|
||||||
|
Queue timeout. Fetching data manually
|
||||||
|
"""
|
||||||
|
raise
|
||||||
except MessageStateError, m:
|
except MessageStateError, m:
|
||||||
logger.error("Message ACK error: %s", m)
|
logger.error("Message ACK error: %s", m)
|
||||||
|
raise
|
||||||
|
except Exception, e:
|
||||||
|
"""
|
||||||
|
There is a problem with the RabbitMq messenger service. Let's
|
||||||
|
log the error and get the schedule via HTTP polling
|
||||||
|
"""
|
||||||
|
logger.error("Exception, %s", e)
|
||||||
|
raise
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
"""
|
"""
|
||||||
There is a problem with the RabbitMq messenger service. Let's
|
Fetch Airtime schedule manually
|
||||||
log the error and get the schedule via HTTP polling
|
|
||||||
"""
|
"""
|
||||||
logger.error("Exception, %s", e)
|
|
||||||
|
|
||||||
status, self.schedule_data = self.api_client.get_schedule()
|
status, self.schedule_data = self.api_client.get_schedule()
|
||||||
if status == 1:
|
if status == 1:
|
||||||
self.process_schedule(self.schedule_data, "scheduler", False)
|
self.process_schedule(self.schedule_data, "scheduler", False)
|
||||||
|
|
Loading…
Reference in New Issue