Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Long response time when calling unmatched requests #473

Open
kob-aha opened this issue Oct 2, 2023 · 0 comments
Open

Long response time when calling unmatched requests #473

kob-aha opened this issue Oct 2, 2023 · 0 comments

Comments

@kob-aha
Copy link

kob-aha commented Oct 2, 2023

I'm using HTTPretty while setting 'allow_net_connect=true' when calling 'enable'. The problem is that when I call an unmatched URL it is forwarded to the real endpoint, however the response time is very long (about 1 sec).

I tried to debug it a little and it seems like HTTPretty uses the real socket and gets a response relatively fast, however it then keeps waiting on the socket for up to a second.

This is the relevant code from real_sendall in core.py:

should_continue = True
while should_continue:
    try:
        received = sock.recv(self._bufsize)
        self.fd.write(received)
        should_continue = bool(received.strip())

    except socket.error as e:
        if e.errno == EAGAIN:
            continue
        break

I see that it gets a response in a few ms and then simply gets stuck on sock.recv usually up to a second until it gets an empty data and exit.
I tested it with different URLs and got the same behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant