hyper
hyper copied to clipboard
AttributeError: 'NoneType' object has no attribute 'fill'
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.
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.
👍
Did this get resolved?
Depends what you mean by resolved. We haven't started raising a better error yet.
Well this AttributeError shouldn't appear though. So in a way it was resolved ;)
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.
Was this bug closed via https://github.com/Lukasa/hyper/commit/4d9262444b43b7b76cf649d853fc04b834d63545 ?
It's certainly possible. Try with the current master and see if you can reproduce.