Skip to content

Connection pooling broken since v2.6.0 #3288

@chriskuehl

Description

@chriskuehl

Connection pooling does not appear to work since v2.6.0. Instead, a new connection is opened to the GitHub server for each request, causing a performance regression. I believe I have traced this down to the introduction of #3060. I will open a PR with a suggested fix.

Reproduction

import os, logging
logging.basicConfig(level=logging.DEBUG)

from github import Github, Auth
auth = Auth.Token(os.environ['GITHUB_TOKEN'])
g = Github(auth=auth)
print(list(g.get_user().get_repos()))

Output (v2.5.0)

$ GITHUB_TOKEN=xxx python test.py
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.github.com:443
DEBUG:urllib3.connectionpool:https://api.github.com:443 "GET /user/repos HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.github.com:443 "GET /user/repos?page=2 HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.github.com:443 "GET /user/repos?page=3 HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.github.com:443 "GET /user/repos?page=4 HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.github.com:443 "GET /user/repos?page=5 HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.github.com:443 "GET /user/repos?page=6 HTTP/1.1" 200 None

Output (v2.6.0 through current main branch)

$ GITHUB_TOKEN=xxx python test.py
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.github.com:443
DEBUG:urllib3.connectionpool:https://api.github.com:443 "GET /user/repos HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.github.com:443
DEBUG:urllib3.connectionpool:https://api.github.com:443 "GET /user/repos?page=2 HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.github.com:443
DEBUG:urllib3.connectionpool:https://api.github.com:443 "GET /user/repos?page=3 HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.github.com:443
DEBUG:urllib3.connectionpool:https://api.github.com:443 "GET /user/repos?page=4 HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.github.com:443
DEBUG:urllib3.connectionpool:https://api.github.com:443 "GET /user/repos?page=5 HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.github.com:443

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions