Poetry: Poetry install throws TypeError when retrying in flakey network

Created on 21 Mar 2019  路  4Comments  路  Source: python-poetry/poetry

  • [x] I am on the latest Poetry version.
  • [x] I have searched the issues of this repo and believe that this is not a duplicate.
  • [ ] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

  • OS version and name: Debian-based (in Docker), Python 3.5

  • Poetry version:
  • TOML here:
[tool.poetry.dependencies]
python = "^3.5"
jsonschema = "^3.0"
numpy = "^1.16"

[tool.poetry.dev-dependencies]
pytest = "^4.3"

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

Issue

First, thanks for a great project. Makes me happy to use Poetry.
It may be this is more of a python-wheels problem than Poetry, not sure. Perhaps the error could be wrapped for users, either way though?

Also, perhaps some similarities to #913?

Steps to replicate

  • Run poetry install on a project with a fair few dependencies
  • Erm, somehow reset one of the network connections during this...

Expected

Retries, or gives up retrying neatly.

Actual

TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'

Background

One CI run died for us recently during poetry install. Looks like the root cause is a broken network connection.
I've tried to fix the formatting from CI logs, still a bit borked, sorry:

[EnvCommandError]
Command ['/root/.cache/pypoetry/virtualenvs/community-models-py3.5/bin/python', '-m', 'pip', 'install', '--no-deps', 'pytest==4.3.0'] errored with the following output:                                                              
Collecting pytest==4.3.0                                                      
Exception:                                                                    
Traceback (most recent call last):                                            
  File "/root/.cache/pypoetry/virtualenvs/community-models-py3.5/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 594, in urlopen                                                             
    chunked=chunked)                                                          
  File "/root/.cache/pypoetry/virtualenvs/community-models-py3.5/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 391, in _make_request                                                      
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/root/.cache/pypoetry/virtualenvs/community-models-py3.5/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 387, in _make_request                                                       
    httplib_response = conn.getresponse()                                     
  File "/usr/lib/python3.5/http/client.py", line 1198, in getresponse         
    response.begin()                                                          
  File "/usr/lib/python3.5/http/client.py", line 297, in begin                
    version, status, reason = self._read_status()                             
  File "/usr/lib/python3.5/http/client.py", line 266, in _read_status         
    raise RemoteDisconnected("Remote end closed connection without"           
http.client.RemoteDisconnected: Remote end closed connection without response                                                                             
During handling of the above exception, another exception occurred:           
Traceback (most recent call last):
  File "/root/.cache/pypoetry/virtualenvs/community-models-py3.5/lib/python3.5/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/root/.cache/pypoetry/virtualenvs/community-models-py3.5/lib/python3.5/site-packages/pip/commands/install.py", line 353, in run
    wb.build(autobuilding=True)
  File "/root/.cache/pypoetry/virtualenvs/community-models-py3.5/lib/python3.5/site-packages/pip/wheel.py", line 749, in build                            
    self.requirement_set.prepare_files(self.finder)                           
  File "/root/.cache/pypoetry/virtualenvs/community-models-py3.5/lib/python3.5/site-packages/pip/req/req_set.py", line 380, in prepare_files              
    ignore_dependencies=self.ignore_dependencies))                            
  File "/root/.cache/pypoetry/virtualenvs/community-models-py3.5/lib/python3.5/site-packages/pip/req/req_set.py", line 620, in _prepare_file              
    session=self.session, hashes=hashes)                                      
  File "/root/.cache/pypoetry/virtualenvs/community-models-py3.5/lib/python3.5/site-packages/pip/download.py", line 821, in unpack_url                    
    hashes=hashes                                                             
  File "/root/.cache/pypoetry/virtualenvs/community-models-py3.5/lib/python3.5/site-packages/pip/download.py", line 659, in unpack_http_url               
    hashes)                                                                   
  File "/root/.cache/pypoetry/virtualenvs/community-models-py3.5/lib/python3.5/site-packages/pip/download.py", line 853, in _download_http_url            
    stream=True,                                                              
  File "/root/.cache/pypoetry/virtualenvs/community-models-py3.5/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 501, in get
    return self.request('GET', url, **kwargs)                                 
  File "/root/.cache/pypoetry/virtualenvs/community-models-py3.5/lib/python3.5/site-packages/pip/download.py", line 386, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)      
  File "/root/.cache/pypoetry/virtualenvs/community-models-py3.5/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 488, in request                                                                 
    resp = self.send(prep, **send_kwargs)                                     
  File "/root/.cache/pypoetry/virtualenvs/community-models-py3.5/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 609, in send                                                                    
    r = adapter.send(request, **kwargs)
  File "/root/.cache/pypoetry/virtualenvs/community-models-py3.5/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/adapter.py",   
line 47, in send                                                              
    resp = super(CacheControlAdapter, self).send(request, **kw)               
  File "/root/.cache/pypoetry/virtualenvs/community-models-py3.5/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/adapters.py", line 423, in send                                                                    
    timeout=timeout                                                           
  File "/root/.cache/pypoetry/virtualenvs/community-models-py3.5/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 643, in urlopen                                                             
    _stacktrace=sys.exc_info()[2])                                            
  File "/root/.cache/pypoetry/virtualenvs/community-models-py3.5/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/util/retry.py", line 315, in increment                                                               
    total -= 1  
TypeError: unsupported operand type(s) for -=: 'Retry' and 'int' 

Most helpful comment

Oh. Your pip just needs updating.

https://stackoverflow.com/questions/37495375/python-pip-install-throws-typeerror-unsupported-operand-types-for-retry

I suggest closing this ticket since it's not about Poetry after all (and hey now we have this issue as docs, thanks to you filing this, and that's great!)

All 4 comments

Noting some versions:

requests-2.12.4
urllib3-1.19.1

Can you dump some info about pip version?

Oh. Your pip just needs updating.

https://stackoverflow.com/questions/37495375/python-pip-install-throws-typeerror-unsupported-operand-types-for-retry

I suggest closing this ticket since it's not about Poetry after all (and hey now we have this issue as docs, thanks to you filing this, and that's great!)

OK. For further documentation, the pip(3) came (via Docker inheritance from here) from the default Debian Stretch repos (i.e. apt-get install python3-pip), which I'd hoped would be "new enough", but clearly it's usual Debian issues.

I guess I'll self-upgrade pip there.

Thanks for the investigation!

@declension Appreciate you mentioning, as I am just about to encounter this in a Debian Docker image where I鈥檓 moving a project to Poetry

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thejohnfreeman picture thejohnfreeman  路  3Comments

jackemuk picture jackemuk  路  3Comments

jhrmnn picture jhrmnn  路  3Comments

ulope picture ulope  路  3Comments

mozartilize picture mozartilize  路  3Comments