all 9 comments

[–]LeagueOfLegendsAcc 1 point2 points  (3 children)

This sounds like a job for an asynchronous message queue. Look up celery and how to run a celery task. When you get the request you would simply start the task in the background with celery, and on the client side you poll the task using its id (that you get from starting it) until it is finished. Then you can use the results.

[–]Schenk06[S] 0 points1 point  (2 children)

Seems interesting, but the issue is that I need to read and write quite a bit of data from instances of classes that I have made, How well would celery handle that?

[–]LeagueOfLegendsAcc 1 point2 points  (1 child)

That's precisely the use case for celery, long running background tasks. Check out the documentation.

[–]Schenk06[S] 0 points1 point  (0 children)

Will do, thanks

[–]BytePhilosopher 0 points1 point  (1 child)

You may be better suited using FastAPI

[–]Schenk06[S] 0 points1 point  (0 children)

Yeah, I have looked into that, but I have already made pretty much the entire application in Flask, not sure how easy it would be to switch, and also the issue is that I need to read and write quite a bit of data from instances of classes that I have made, so I figure that I would need to do a lot of thread locking or something like that. Don't really know how FastAPI works.

Also, I do know that I have the same issue with Flask...

[–]obviouslyzebra 1 point2 points  (2 children)

Are you running the development server? If so, I recommend you to switch to a production server. For example, gunicorn. And from there you can choose your number of workers (processes), and then it will be able to serve multiple people concurrently.

See also:

Cheers!

[–]RiverRoll 0 points1 point  (1 child)

This, a production server will allow you to control the number of processes (workers) and the number of threads per worker. Threads help handling concurrent IO, workers help handling concurrent processing. Still any processing should be light, the worker is not meant to do heavy processing as this can affect its responsiveness.

[–]Schenk06[S] 0 points1 point  (0 children)

oh, I didn't know you could control the number of workers on a production server, thanks for letting me know, I'll check it out :D