I'm working on a Flask app that allows users to configure and schedule reports at a later time. I'm utilizing Flask-APScheduler to handle the scheduling, then inside the callback function I'm passing the actual task off to a redis-queue. What I want to do is before submitting the task to the redis queue I want to create a unique logfile name for that task, save it in my database, then send it off to the queue.
The reason I want to do this is so that I can allow users to click on a running task and view the logs in real-time.
My question really becomes: How can I create a SocketIO Flask App when that task starts, so that it can stream the logs to the browser if a user is viewing that particular task's logs?
I think where I'm getting caught up is how I would determine which SocketIO Flask App to connect to on the browser-side to stream the right logs. From my perspective (which could be incorrect), it looks like I'd need to create one SocketIO Flask App per task, even though it seems logical to utilize a single SocketIO Flask App and just declare one channel per redis task, but since redis task workers function independent of each other, how would that even be plausible?
A side note: My main app is a plain Flask App that is not utilizing SocketIO. I'm just looking to communicate info (stream lines of the logs) from the background rq worker processes to the browser/frontend for the end-user to see.
I'm working on a Flask app that allows users to configure and schedule reports at a later time. I'm utilizing Flask-APScheduler to handle the scheduling, then inside the callback function I'm passing the actual task off to a redis-queue. What I want to do is before submitting the task to the redis queue I want to create a unique logfile name for that task, save it in my database, then send it off to the queue.
The reason I want to do this is so that I can allow users to click on a running task and view the logs in real-time.
My question really becomes: How can I create a SocketIO Flask App when that task starts, so that it can stream the logs to the browser if a user is viewing that particular task's logs?
I think where I'm getting caught up is how I would determine which SocketIO Flask App to connect to on the browser-side to stream the right logs. From my perspective (which could be incorrect), it looks like I'd need to create one SocketIO Flask App per task, even though it seems logical to utilize a single SocketIO Flask App and just declare one channel per redis task, but since redis task workers function independent of each other, how would that even be plausible?
A side note: My main app is a plain Flask App that is not utilizing SocketIO. I'm just looking to communicate info (stream lines of the logs) from the background rq worker processes to the browser/frontend for the end-user to see.