python-hyper / hyper

HTTP/2 for Python.
http://hyper.rtfd.org/en/latest/
MIT License
1.05k stars 192 forks source link

AttributeError: 'NoneType' object has no attribute 'fill' #272

Open 72squared opened 8 years ago

72squared commented 8 years ago

I see this error very intermittently (1 in a million requests?) while using apns2 package:

https://github.com/Pr0Ger/PyAPNs2/tree/master/apns2

Here's the traceback:

File /opt/venv-marcopolo/local/lib/python2.7/site-packages/hyper/http20/connection.py, line 293, in get_response return HTTP20Response(stream.getheaders(), stream)
File /opt/venv-marcopolo/local/lib/python2.7/site-packages/hyper/http20/stream.py, line 223, in getheaders self._recv_cb(stream_id=self.stream_id) 
File /opt/venv-marcopolo/local/lib/python2.7/site-packages/hyper/http20/connection.py, line 744, in _recv_cb self._single_read() 
File /opt/venv-marcopolo/local/lib/python2.7/site-packages/hyper/http20/connection.py, line 644, in _single_read self._sock.fill() 
AttributeError: 'NoneType' object has no attribute 'fill'

It is using the 0.6.2 hyper release. I haven't compared against using older versions of hyper.

Lukasa commented 8 years ago

So I think this occurs when the connection has been closed while a read was queued up. We should probably raise ConnectionResetError in this case.

72squared commented 8 years ago

👍

johnmanong commented 7 years ago

Did this get resolved?

Lukasa commented 7 years ago

Depends what you mean by resolved. We haven't started raising a better error yet.

sigmavirus24 commented 7 years ago

Well this AttributeError shouldn't appear though. So in a way it was resolved ;)

jrconlin commented 7 years ago

I've seen this error crop up while talking to APNS, which seems to be SUPER AGGRESSIVE about prematurely terminating connections. Generally, I see it pop when trying to read response headers. I just wrap the parent call to trap for (HTTP20Error, AttributeError) which fixes this.

Someone could just wrap https://github.com/Lukasa/hyper/blob/development/hyper/http20/stream.py#L228 and that would probably catch most of these.

jrconlin commented 7 years ago

Was this bug closed via https://github.com/Lukasa/hyper/commit/4d9262444b43b7b76cf649d853fc04b834d63545 ?

Lukasa commented 7 years ago

It's certainly possible. Try with the current master and see if you can reproduce.