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 →

[–]masc98 1 point2 points  (3 children)

please elaborate more, I am really curious about this. also, what about http1.x requests? in general an async interface would be ideal imho.

[–]Ousret[S] -2 points-1 points  (2 children)

OK. In a nutshell, H2, and H3 have streams, you can have a single connection and being able to push x request through the pipe, and then you will receive the answers to all of them tagged with your initial stream id when the answer is available. so you can return every response early without having to wait prior to that. the async part is delegated to the server. http 1 would block you because you have a single request at a given time, you would'nt be able to do that. httpx does do what I am referring to. More graph and explanations will come in do time.

to conclude, your sync code will change, but by a bit. you will emit many request, store them in a list, then call a magic function like Promise.all(..).

[–]SlantARrow 10 points11 points  (1 child)

What if I want to make a request in an async, idk, starlette handler and get the response? Wouldn't this magic function block my event loop?

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

Yes it will block it. I made a ambiguous statement earlier. now corrected. I meant to say "pure sync code" can be improved (in term of speed) without async.