Skip to content

Random KeyErrors when performing GET requests (possible race condition) #581

Closed

Description

@KyleKreutzer

When performing a get request using httpx.client.get, I am (with every 1/10 requests or so) getting random key errors. The only argument being handed to this call is a 5 second timeout, a google "NID" cookie, and the URL. I've attached a text file with the error.
KeyError.txt

Activity

  1. lovelydinosaur commented on Dec 2, 2019

    @lovelydinosaur
    Member

    Thanks for reporting this.

    What's the simplest possible example that reproduces this reliably?
    Is this only occuring against a specific URL, or can you determine various cases where its failing?

  2. KyleKreutzer commented on Dec 2, 2019

    @KyleKreutzer
    Author

    I've only tried it against the Google Trends API (https://trends.google.com/trends/api/*). The simplest way to reproduce the error would be to pull https://github.com/KyleKreutzer/pytrends-async and run the unit tests using pytest w/pytest-asyncio. The problem is occurring intermittently so it may take more than 1 run to have the issue appear, but any of those tests seem to reliably reproduce the problem.

    Edit:
    I noticed that I did not have my Client objects wrapped with async with. I tried adding this, and it has not fixed the issue.

  3. KyleKreutzer commented on Dec 2, 2019

    @KyleKreutzer
    Author
        for i in range(100):
            async with httpx.Client() as c:
                resp = await c.get('https://trends.google.com/?geo={geo}'.format(geo='US'), timeout=5)
                time.sleep(1)
    

    This will reproduce the bug

  4. millefalcon commented on Dec 6, 2019

    @millefalcon
    Contributor

    Is this still reproducible ?
    Couldn't reproduce it with:

    python3.6.9
    trio==0.13.0
    git+https://github.com/encode/httpx@75a439d7e2120edcddd8213df27dfeea28a2dc8c#egg=httpx
    
  5. KyleKreutzer commented on Dec 6, 2019

    @KyleKreutzer
    Author

    I was able to reproduce it again with above code snippet on both mac and windows using 3.7.0 and 3.7.3. I am not using trio and am using version httpx==0.8.0 from pypi.

  6. lovelydinosaur commented on Dec 8, 2019

    @lovelydinosaur
    Member

    Closed in master via #612

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    http/2Issues and PRs related to HTTP/2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions