1. Simple Exception Handling


This is what we used to have to handle errors.
However, that except case occurred pretty much every endpoint with the same behaviour. Hence, we decided to create a decorator to be able to reuse it instead of having duplication.


A decorator to handle exceptions.

After implementing a decorator into one of the endpoints.

2. Logging


We want to log pretty much everything but instead of saving into one file, we want to create log files daily basis.


For instance,

To achieve this, we used a handler called `TimedRotatingFileHandler`. However, with `TimedRotatingFileHandler`, using multiple processes is not safe/good to work with when we are currently using six processes. Hence, to prevent potential issues, we had to create a custom handler to override `TimedRotatingFileHandler`.


By using a `multiprocessing.lock()`, we could manage to allocate to a process to work with logging.


Outputs are as following, during this test, we asked to create a log file every minute (only if something occurred, it doesn't just create a log file every minute) whereas now we set to create a logfile on every midnight

3. Download Data


The way I implemented is not a way we are after and will be updated after discussing with Claudio. (It is converting JSON to CSV and export as .csv file)



  • No labels