refactor(playout): improve exceptions handling (#2027)

This commit is contained in:
Jonas L 2022-08-09 21:05:21 +02:00 committed by GitHub
parent 1b93b7645e
commit 9413bd5a29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 123 additions and 169 deletions

View file

@ -1,6 +1,5 @@
import json
import time
import traceback
from threading import Thread
# For RabbitMQ
@ -49,8 +48,8 @@ class PypoMessageHandler(Thread):
) as connection:
rabbit = RabbitConsumer(connection, [schedule_queue], self)
rabbit.run()
except Exception as e:
logger.error(e)
except Exception as exception:
logger.exception(exception)
# Handle a message from RabbitMQ, put it into our yucky global var.
# Hopefully there is a better way to do this.
@ -97,15 +96,14 @@ class PypoMessageHandler(Thread):
self.recorder_queue.put(message)
else:
logger.info("Unknown command: %s" % command)
except Exception as e:
logger.error("Exception in handling RabbitMQ message: %s", e)
except Exception as exception:
logger.exception(exception)
def main(self):
try:
self.init_rabbit_mq()
except Exception as e:
logger.error("Exception: %s", e)
logger.error("traceback: %s", traceback.format_exc())
except Exception as exception:
logger.exception(exception)
logger.error("Error connecting to RabbitMQ Server. Trying again in few seconds")
time.sleep(5)