Тёмный
Code Collider
Code Collider
Code Collider
Подписаться
I make intermediate and advanced backend software development related videos.
How FastAPI Handles Requests Behind the Scenes
5:09
5 месяцев назад
Комментарии
@joelstevick1533
@joelstevick1533 4 дня назад
Nice video!
@hyakuheli
@hyakuheli 6 дней назад
what happens if the server is created with multiple processes (for multiple cores) with uvicorn main:app --workers 4. The first 4 clients are given a new process? or it can be either a process or another thread if a thread is in a non-blocking task? and what happens when there are more than 4 clients at the same time in this case? the new clients are assigned to threads randomly across the 4 processes?
@PriyankRupareliya
@PriyankRupareliya 7 дней назад
This is very valuable content. New job, starting to work on FastAPI. The whole python paradigm is new for me. This video helped clear one of the most critical concept for me. Thanks brother.
@adityahpatel
@adityahpatel 17 дней назад
2 and 3 look the same. hello of each is printed first then bye from each. how is 2 and 3 different? its not explained crystal clearly
@RaadClub
@RaadClub 19 дней назад
Thanks man.
@ArulMuruganAS
@ArulMuruganAS 25 дней назад
its working as explained in unix but for some reason its a different behavior in windows
@harikrishnanb7273
@harikrishnanb7273 25 дней назад
is there a english version?
@startup_cult
@startup_cult Месяц назад
this is such an underrated video
@ashwinabrahamjacob525
@ashwinabrahamjacob525 Месяц назад
great video
@diwakardayalan
@diwakardayalan Месяц назад
Excellent…can it create mock test involving AWS services?
@rainbowrunner1136
@rainbowrunner1136 Месяц назад
Hello, great video. I am super new to python. And started using very recently for backend where its being used along with FastAPI. Can you please tell me what are some concepts/ topics which I should be aware for developing efficient code. For eg from this video, I learnt that which function runs concurrently and which doesn't. I had no idea tbh about this before. If you could spare few minutes and share some stuff which I should know it would be great.
@apefu
@apefu Месяц назад
I have so many questions, I am so sorry. Should you pass app to the AsyncClient() as well for the ASGI server? Also, how would the last example affect APIRouters defined in separate files? How would they reach app.client? They could have their separate lifespan function but wouldn't it be prefered to use the same object? Also, I don't know, but wouldn't it be better to use app.state.client? Oh, and what about POST requests, would you still use the Request object to reach the client? It works, but it gets messy code wise.
@rohit1kumar
@rohit1kumar 2 месяца назад
got any benchmarks?
@Gameplay-ps9ub
@Gameplay-ps9ub 2 месяца назад
Well issue with this kind of libraries imho is, that real life code is not a single module separated from everything else. It's much bigger than that and has a ton of dependencies and/or setup and tear down required. Some tests require quite a lot of fixtures and some of those fixtures are configurable as well. Conclusion is...I'd have to change manually great majority of that auto generated tests to make them any good, so I might as well right them on my own from scratch. And it doesn't support python 3.11+, so it's a big issue.
@НиколайРюмин-й6и
@НиколайРюмин-й6и 2 месяца назад
oh, sorry, that was a hook for further story
@НиколайРюмин-й6и
@НиколайРюмин-й6и 2 месяца назад
Maybe better practice to read chunks from file is async for?
@MakeDataUseful
@MakeDataUseful 2 месяца назад
Great video, thanks for sharing
@Shane1994322
@Shane1994322 3 месяца назад
Clearly explained!! Thank you
@badrakhariunchimeg1031
@badrakhariunchimeg1031 3 месяца назад
Well fastapi ( fun get ( ))
@PyPeak
@PyPeak 3 месяца назад
Beautifully explained!
@mattstroker3742
@mattstroker3742 3 месяца назад
Nice!
@vikranttyagiRN
@vikranttyagiRN 3 месяца назад
Nice explanation. Concise and to the point.
@oktay9784
@oktay9784 3 месяца назад
this is not about FastApi, its about sync functions and async functions so just dont use sync functions in async functions if sync one is takes a lot of time.
@MakeDataUseful
@MakeDataUseful 2 месяца назад
This is a fastAPI video
@805bluebell
@805bluebell 2 месяца назад
It's actually both. End of argument
@sticksen
@sticksen 3 месяца назад
My question would be how FastAPI then manages workload when it´s handed over to the worker thread. Because I can only see one worker thread running, at the same time it handles 40 'workloads' concurrently.
@sany2k8
@sany2k8 3 месяца назад
Great explanation, you should create more videos bro...
@arjunc5896
@arjunc5896 3 месяца назад
def endpoint3() is not running parallely for me as supposed to what u said in the video. Instead it is sunning one at a time. Do u know why?
@codecollider
@codecollider 3 месяца назад
I believe you are testing APIs in the browser. Sometimes, browsers like Chrome have limitations on making parallel requests to the same URL. In the video, if you look closely, I am using two different browsers to hit the same API in parallel. You can try the same approach.
@arjunc5896
@arjunc5896 3 месяца назад
@@codecollider Yes you are right. I tried from different browsers and it worked. Strange though. Thanks
@nitishvirtual4745
@nitishvirtual4745 3 месяца назад
Great video. Short and to the point. Subscribed.
@ChrisHalden007
@ChrisHalden007 3 месяца назад
Great video. Thanks
@ahmedelnakeeb5853
@ahmedelnakeeb5853 4 месяца назад
this should boom i love ur channel
@lwangacaleb2729
@lwangacaleb2729 4 месяца назад
I need some help, I want to create a fast api endpoint that calls a synchronous function that has a lot of blocking I/0 operations. But I want the endpoint function to run asynchronously so it can accept many requests at the same time. How should I do this, is there an alternative approach?
@Praise-rs4mc
@Praise-rs4mc 3 месяца назад
The only way to achieve that is to use multi-threading which I advice against.... instead, make the function asynchronous and try to find the non-blocking function for what you want to do...
@Praise-rs4mc
@Praise-rs4mc 3 месяца назад
Better still, use the run_in_threadpool function from fastapi to run the process in a different thread so that you don't block the event...better than implementing multi threading on your own.
@lwangacaleb2729
@lwangacaleb2729 3 месяца назад
@@Praise-rs4mc thanks alot, I will give it a try.
@shantanudas6319
@shantanudas6319 4 месяца назад
Crisp and clear ❤
@ChrisHalden007
@ChrisHalden007 4 месяца назад
Great video. Thanks
@amodsahabandu
@amodsahabandu 4 месяца назад
Thanks. ❤
@thanosaur6741
@thanosaur6741 4 месяца назад
great video
@robertavetisyan8282
@robertavetisyan8282 4 месяца назад
boooozi txeq
@richardboreiko
@richardboreiko 4 месяца назад
Why not just return condition?
@codecollider
@codecollider 4 месяца назад
Using `return condition` directly is more efficient when you only need to return the boolean value itself. However, the purpose of my comparison was to explore different styles of conditional statements and their performance, especially in scenarios where the if-else structure is necessary for more complex logic.
@suen-tech
@suen-tech 4 месяца назад
Thnx
@user-sh1fv9mm2v
@user-sh1fv9mm2v 4 месяца назад
I always upload with just an post.
@SAsquirtle
@SAsquirtle 4 месяца назад
very nice video, thanks!
@udaym4204
@udaym4204 4 месяца назад
can you make fastapi how run under the hood and how @app.exception_handler work Thanks awesome contentent
@ishaquenizamani9800
@ishaquenizamani9800 4 месяца назад
Thanks for clearing this concept.
@boringhuman9427
@boringhuman9427 4 месяца назад
As per LEGB rule , it is considered as enclosed variable - neither local or global but behaves as local and global within a function more specifically under decorators
@MakeDataUseful
@MakeDataUseful 2 месяца назад
Local, Enclosing, Global, and Built-in scopes for those playing along at home
@user-sh1fv9mm2v
@user-sh1fv9mm2v 4 месяца назад
Your videos are the best. No bs, just facts.
@MathClubfor6789
@MathClubfor6789 4 месяца назад
Great knowledgable video
@temirlllan
@temirlllan 4 месяца назад
thx bro! so useful material, keep going
@myselfriz
@myselfriz 4 месяца назад
very well explanation.
@cyyan1139
@cyyan1139 4 месяца назад
thank you!
@pritamsarkar3371
@pritamsarkar3371 4 месяца назад
dont we have to enable the 68 no line? "app = Fastapi(lifespan=lifespan)" ?
@codecollider
@codecollider 4 месяца назад
Yes you have to uncomment that line if you are using lifespan, forget to tell in the video.
@seva9375
@seva9375 5 месяцев назад
Hello I am not able to run Pynguin. I tryed your approach and got this error: (base) seva@air-von-seva Pynguin_input % pynguin --project-path . --module-name test_example_2 --output-path . Traceback (most recent call last): File "/Users/seva/anaconda3/bin/pynguin", line 5, in <module> from pynguin.cli import main File "/Users/seva/anaconda3/lib/python3.11/site-packages/pynguin/__init__.py", line 9, in <module> import pynguin.generator as gen File "/Users/seva/anaconda3/lib/python3.11/site-packages/pynguin/generator.py", line 31, in <module> import pynguin.analyses.seeding as seeding # pylint: disable=consider-using-from-import ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/seva/anaconda3/lib/python3.11/site-packages/pynguin/analyses/seeding.py", line 25, in <module> import pynguin.ga.testcasechromosome as tcc File "/Users/seva/anaconda3/lib/python3.11/site-packages/pynguin/ga/testcasechromosome.py", line 13, in <module> import pynguin.ga.chromosome as chrom File "/Users/seva/anaconda3/lib/python3.11/site-packages/pynguin/ga/chromosome.py", line 13, in <module> import pynguin.ga.computations as ff File "/Users/seva/anaconda3/lib/python3.11/site-packages/pynguin/ga/computations.py", line 17, in <module> from pynguin.testcase.execution import ExecutionTrace File "/Users/seva/anaconda3/lib/python3.11/site-packages/pynguin/testcase/execution.py", line 425, in <module> class ExecutionTracer: File "/Users/seva/anaconda3/lib/python3.11/site-packages/pynguin/testcase/execution.py", line 460, in ExecutionTracer Compare.IN: lambda val1, val2: ( ^^^^^^^^^^ File "/Users/seva/anaconda3/lib/python3.11/enum.py", line 784, in __getattr__ raise AttributeError(name) from None AttributeError: IN
@lucaspraciano4640
@lucaspraciano4640 5 месяцев назад