Skip to content
Discussion options

You must be logged in to vote

@nilansaha How are you performing the requests? I found some time ago that (some) browsers (Firefox in my case) seem to avoid performing simultaneous requests to the same endpoint (or localhost?).

Maybe try this code to perform N concurrent requests using Python, I'd say your example would work as expected after trying it:

import threading
import requests

N_REQUESTS = 5

def req():
	requests.get("http://localhost:8000/hi")

threads = [threading.Thread(target=req, daemon=True) for _ in range(N_REQUESTS)]
[th.start() for th in threads]
[th.join() for th in threads]

Output from fastapi server:

INFO:     Started server process [33905]
INFO:     Waiting for application startup.
INFO:     Appl…

Replies: 7 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Kludex
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem question-migrate
5 participants
Converted from issue

This discussion was converted from issue #3363 on February 27, 2023 22:49.