Skip to content

AttributeError: 'GitHubSession' object has no attribute 'default_connect_timeout' #946

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

Closed
nedbat opened this issue Jun 4, 2019 · 3 comments

Comments

@nedbat
Copy link
Contributor

nedbat commented Jun 4, 2019

I upgraded github3.py from 0.9.6 to 1.3.0. After adjusting the names of iter_ functions, and a few other small changes, my program fails with a mysterious error:

Traceback (most recent call last):
  File "/usr/local/virtualenvs/repo-tools/bin/tag_release", line 9, in <module>
    load_entry_point('edx-repo-tools==0.1', 'console_scripts', 'tag_release')()
  File "/usr/local/virtualenvs/repo-tools/lib/python2.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/virtualenvs/repo-tools/lib/python2.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/virtualenvs/repo-tools/lib/python2.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/virtualenvs/repo-tools/lib/python2.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/src/edx/repo-tools/repo-tools/edx_repo_tools/auth.py", line 204, in wrapped
    f(hub=hub, *args, **kwargs)
  File "/src/edx/repo-tools/repo-tools/edx_repo_tools/release/tag_release.py", line 584, in main
    existing_refs = get_ref_for_repos(repos, ref, use_tag=use_tag)
  File "/src/edx/repo-tools/repo-tools/edx_repo_tools/release/tag_release.py", line 251, in get_ref_for_repos
    ref_obj = repo.ref(ref)
  File "/usr/local/virtualenvs/repo-tools/lib/python2.7/site-packages/github3/repos/repo.py", line 2444, in ref
    json = self._json(self._get(url), 200)
  File "/usr/local/virtualenvs/repo-tools/lib/python2.7/site-packages/github3/models.py", line 211, in _get
    return self._request("get", url, **kwargs)
  File "/usr/local/virtualenvs/repo-tools/lib/python2.7/site-packages/github3/models.py", line 196, in _request
    return request_method(*args, **kwargs)
  File "/usr/local/virtualenvs/repo-tools/lib/python2.7/site-packages/requests/sessions.py", line 546, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/virtualenvs/repo-tools/lib/python2.7/site-packages/github3/session.py", line 171, in request
    kwargs.setdefault("timeout", self.timeout)
  File "/usr/local/virtualenvs/repo-tools/lib/python2.7/site-packages/github3/session.py", line 121, in timeout
    return (self.default_connect_timeout, self.default_read_timeout)
AttributeError: 'GitHubSession' object has no attribute 'default_connect_timeout'

I added print statements to track the ids of sessions in a few places: __init__ for GitHubSession and requests.Session, and in GitHubSession.request. It seems that the GitHubSession object exists, but never had __init__ run on it? I don't understand how that is possible.

I don't have a simple reproducer, though I will work at creating one. I'm hoping something about this will be more obvious to a github3.py developer. Maybe there's something about my code I haven't updated properly yet?

Version Information

Please provide:

  • The version of Python you're using: 2.7.14

  • The version of pip you used to install github3.py: 19.1.1

  • The version of github3.py, requests, uritemplate, and dateutil installed:
    Full pip freeze:

apipkg==1.5 appdirs==1.4.3 asn1crypto==0.24.0 atomicwrites==1.3.0 attrs==19.1.0 certifi==2019.3.9 cffi==1.12.3 chardet==3.0.4 Click==7.0 configparser==3.7.4 contextlib2==0.5.5 cryptography==2.7 -e git+git@github.com:edx/repo-tools.git@3f7010f9a94b776005f56d86f79114dbb798c566#egg=edx_repo_tools enum34==1.1.6 execnet==1.6.0 funcsigs==1.0.2 github3.py==1.3.0 idna==2.8 importlib-metadata==0.17 ipaddress==1.0.22 jwcrypto==0.6.0 lazy==1.4 more-itertools==5.0.0 packaging==19.0 pathlib2==2.3.3 pluggy==0.12.0 pudb==2019.1 py==1.8.0 pycparser==2.19 Pygments==2.4.2 pyparsing==2.4.0 pytest==4.6.2 pytest-forked==1.0.2 pytest-xdist==1.28.0 python-dateutil==2.8.0 PyYAML==5.1 requests==2.22.0 scandir==1.10.0 six==1.12.0 uritemplate==3.0.0 urllib3==1.25.3 urwid==2.0.1 wcwidth==0.1.7 zipp==0.5.1
@sigmavirus24
Copy link
Owner

@nedbat
Copy link
Contributor Author

nedbat commented Jun 4, 2019

You're a genius! Fixed in this pull request: #947

sigmavirus24 added a commit that referenced this issue Jun 5, 2019
Add all GitHubSession attributes to __attrs__. #946
@sigmavirus24
Copy link
Owner

Also, I wonder if this speaks to a need that I wasn't aware of - namely a need to copy+munge things by people safely without breaking gh3py's expectations.

@nedbat nedbat closed this as completed Jun 5, 2019
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

2 participants