I am trying to create a client-server app in which the client can send a HTTP request with files to the server to start a process of training an AI model. I want the client to be able to get updates about the progress.
There are some issues though.
See the process of training just as a function (model.train(...)
) which takes a very long time. So I would have to run it on another thread / process.
The problem with running it on another thread is that, I cannot force stop this specific thread if a HTTP request comes from the client to stop it.
If I use multiprocessing, and just run it on a new process, I can solve this issue.
But a new problem arises, and that is now I can’t constantly send updates to the client, because the training just runs on another process, and I can’t use the starting socketio = SocketIO(app, cors_allowed_origins="*")
.
How would I solve this? I can only update the client from the main process. Do I have to create a thread for both processes so that the thread from the second process sends information to the thread of first process?
I am not uploading any code since it’s pretty pointless and complicated, I just explained through which kind of issues I got. I kind of need a plan of organizing this.
vct12345 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.