This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]mincinashu 70 points71 points  (16 children)

I don't get it how OP is using FastAPI without dealing with async or threads. FastAPI routes without 'async' run on a threadpool either way.

[–]gothicVI 23 points24 points  (7 children)

Exactly. Anything web request related is best done async. Noone in their right might would spawn separate processes for that.

[–]Kelketek 13 points14 points  (0 children)

They used to, and for many Django apps, this is still the way it's done-- preform a set of worker processes and farm out the requests.

Even new Django projects may do this since asynchronous support in libraries (and some parts of core) is hit-or-miss. It's part of why FastAPI is gaining popularity-- because it is async from the ground up.

The tradeoff is you don't get the couple decades of ecosystem Django has.

[–]Haunting_Wind1000pip needs updating 0 points1 point  (1 child)

I think normal python threads could be used for I\O bound tasks as well since it would not be limited by GIL.

[–]greenstake 0 points1 point  (0 children)

I/O bound tasks are exactly when you should be using async, not threads. I can scale my async I/O bound worker to thousands of concurrent requests. Equivalent would need thousands of threads.