simultaneously receive logs from Rabbitmq and run your flask app simultaneously receive logs from Rabbitmq and run your flask app flask flask

simultaneously receive logs from Rabbitmq and run your flask app


Your flask app, here the main thread, runs for an amount of time or an amount of requests determined by your uwsgi or whatever else you are using to run it. When the main process stops, it will most likely be the wrong time to gracefully close your amqp connection.

Moreover, there could be more than one instance of your application running at the same time (think uwsgi processes), so you would get bits of logs on each worker/process.

The sane approach here is to keep these two things separate. Run a consumer process for your logs outside the scope of your web application, ie: with supervisord.