oanda / v20-python

OANDA v20 bindings for Python
MIT License
225 stars 91 forks source link

Unhandled exceptions #12

Closed alekna closed 7 years ago

alekna commented 8 years ago

I've got the following unhandled exception while streaming rates with your wrapper:

2016-11-18T22:31:01.419004000Z Traceback (most recent call last):
2016-11-18T22:31:01.419176000Z   File "/usr/lib/python3.5/site-packages/requests/packages/urllib3/response.py", line 451, in _update_chunk_length
2016-11-18T22:31:01.484328000Z     self.chunk_left = int(line, 16)
2016-11-18T22:31:01.484500000Z ValueError: invalid literal for int() with base 16: b''
2016-11-18T22:31:01.484735000Z During handling of the above exception, another exception occurred:
2016-11-18T22:31:01.484943000Z Traceback (most recent call last):
2016-11-18T22:31:01.485080000Z   File "/usr/lib/python3.5/site-packages/requests/packages/urllib3/response.py", line 232, in _error_catcher
2016-11-18T22:31:01.485200000Z     yield
2016-11-18T22:31:01.485305000Z   File "/usr/lib/python3.5/site-packages/requests/packages/urllib3/response.py", line 502, in read_chunked
2016-11-18T22:31:01.485427000Z     self._update_chunk_length()
2016-11-18T22:31:01.485535000Z   File "/usr/lib/python3.5/site-packages/requests/packages/urllib3/response.py", line 455, in _update_chunk_length
2016-11-18T22:31:01.486292000Z     raise httplib.IncompleteRead(line)
2016-11-18T22:31:01.486446000Z http.client.IncompleteRead: IncompleteRead(0 bytes read)
2016-11-18T22:31:01.486664000Z During handling of the above exception, another exception occurred:
2016-11-18T22:31:01.486874000Z Traceback (most recent call last):
2016-11-18T22:31:01.486979000Z   File "/usr/lib/python3.5/site-packages/requests/models.py", line 676, in generate
2016-11-18T22:31:01.640070000Z     for chunk in self.raw.stream(chunk_size, decode_content=True):
2016-11-18T22:31:01.640242000Z   File "/usr/lib/python3.5/site-packages/requests/packages/urllib3/response.py", line 353, in stream
2016-11-18T22:31:01.640381000Z     for line in self.read_chunked(amt, decode_content=decode_content):
2016-11-18T22:31:01.640497000Z   File "/usr/lib/python3.5/site-packages/requests/packages/urllib3/response.py", line 530, in read_chunked
2016-11-18T22:31:01.640613000Z     self._original_response.close()
2016-11-18T22:31:01.640730000Z   File "/usr/lib64/python3.5/contextlib.py", line 77, in __exit__
2016-11-18T22:31:01.670915000Z     self.gen.throw(type, value, traceback)
2016-11-18T22:31:01.671048000Z   File "/usr/lib/python3.5/site-packages/requests/packages/urllib3/response.py", line 250, in _error_catcher
2016-11-18T22:31:01.671173000Z     raise ProtocolError('Connection broken: %r' % e, e)
2016-11-18T22:31:01.671286000Z requests.packages.urllib3.exceptions.ProtocolError: ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))
2016-11-18T22:31:01.671535000Z During handling of the above exception, another exception occurred:
2016-11-18T22:31:01.671750000Z Traceback (most recent call last):
2016-11-18T22:31:01.671888000Z   File "/app/proxy.py", line 84, in <module>
2016-11-18T22:31:01.671996000Z     main()
2016-11-18T22:31:01.672104000Z   File "/app/proxy.py", line 65, in main
2016-11-18T22:31:01.672709000Z     for msg_type, msg in response.parts():
2016-11-18T22:31:01.672839000Z   File "/usr/lib/python3.5/site-packages/v20/response.py", line 52, in parts
2016-11-18T22:31:01.696608000Z     for line in self.lines:
2016-11-18T22:31:01.696744000Z   File "/usr/lib/python3.5/site-packages/requests/models.py", line 720, in iter_lines
2016-11-18T22:31:01.696857000Z     for chunk in self.iter_content(chunk_size=chunk_size, decode_unicode=decode_unicode):
2016-11-18T22:31:01.696965000Z   File "/usr/lib/python3.5/site-packages/requests/models.py", line 679, in generate
2016-11-18T22:31:01.697071000Z     raise ChunkedEncodingError(e)
2016-11-18T22:31:01.697191000Z requests.exceptions.ChunkedEncodingError: ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))
alekna commented 8 years ago

And here it happened again.

As I understand this happens during the maintenance when you take down API servers or load-balancers, or both.

Please wrap those additional exceptions under V20ConnectionError.

2016-11-25T23:42:31.118060000Z Traceback (most recent call last):
2016-11-25T23:42:31.118243000Z   File "/usr/lib/python3.5/site-packages/requests/packages/urllib3/response.py", line 451, in _update_chunk_length
2016-11-25T23:42:31.175740000Z     self.chunk_left = int(line, 16)
2016-11-25T23:42:31.175898000Z ValueError: invalid literal for int() with base 16: b''
2016-11-25T23:42:31.176170000Z During handling of the above exception, another exception occurred:
2016-11-25T23:42:31.176414000Z Traceback (most recent call last):
2016-11-25T23:42:31.176523000Z   File "/usr/lib/python3.5/site-packages/requests/packages/urllib3/response.py", line 232, in _error_catcher
2016-11-25T23:42:31.176630000Z     yield
2016-11-25T23:42:31.176737000Z   File "/usr/lib/python3.5/site-packages/requests/packages/urllib3/response.py", line 502, in read_chunked
2016-11-25T23:42:31.176852000Z     self._update_chunk_length()
2016-11-25T23:42:31.176964000Z   File "/usr/lib/python3.5/site-packages/requests/packages/urllib3/response.py", line 455, in _update_chunk_length
2016-11-25T23:42:31.177748000Z     raise httplib.IncompleteRead(line)
2016-11-25T23:42:31.177873000Z http.client.IncompleteRead: IncompleteRead(0 bytes read)
2016-11-25T23:42:31.178107000Z During handling of the above exception, another exception occurred:
2016-11-25T23:42:31.178359000Z Traceback (most recent call last):
2016-11-25T23:42:31.178472000Z   File "/usr/lib/python3.5/site-packages/requests/models.py", line 676, in generate
2016-11-25T23:42:31.196889000Z     for chunk in self.raw.stream(chunk_size, decode_content=True):
2016-11-25T23:42:31.197068000Z   File "/usr/lib/python3.5/site-packages/requests/packages/urllib3/response.py", line 353, in stream
2016-11-25T23:42:31.197189000Z     for line in self.read_chunked(amt, decode_content=decode_content):
2016-11-25T23:42:31.197309000Z   File "/usr/lib/python3.5/site-packages/requests/packages/urllib3/response.py", line 530, in read_chunked
2016-11-25T23:42:31.197485000Z     self._original_response.close()
2016-11-25T23:42:31.197630000Z   File "/usr/lib64/python3.5/contextlib.py", line 77, in __exit__
2016-11-25T23:42:31.219085000Z     self.gen.throw(type, value, traceback)
2016-11-25T23:42:31.219253000Z   File "/usr/lib/python3.5/site-packages/requests/packages/urllib3/response.py", line 250, in _error_catcher
2016-11-25T23:42:31.219386000Z     raise ProtocolError('Connection broken: %r' % e, e)
2016-11-25T23:42:31.219500000Z requests.packages.urllib3.exceptions.ProtocolError: ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))
2016-11-25T23:42:31.219767000Z During handling of the above exception, another exception occurred:
2016-11-25T23:42:31.219993000Z Traceback (most recent call last):
2016-11-25T23:42:31.220102000Z   File "/app/proxy.py", line 84, in <module>
2016-11-25T23:42:31.226892000Z     main()
2016-11-25T23:42:31.227023000Z   File "/app/proxy.py", line 65, in main
2016-11-25T23:42:31.227146000Z     for msg_type, msg in response.parts():
2016-11-25T23:42:31.227267000Z   File "/usr/lib/python3.5/site-packages/v20/response.py", line 52, in parts
2016-11-25T23:42:31.235043000Z     for line in self.lines:
2016-11-25T23:42:31.235195000Z   File "/usr/lib/python3.5/site-packages/requests/models.py", line 720, in iter_lines
2016-11-25T23:42:31.235313000Z     for chunk in self.iter_content(chunk_size=chunk_size, decode_unicode=decode_unicode):
2016-11-25T23:42:31.235444000Z   File "/usr/lib/python3.5/site-packages/requests/models.py", line 679, in generate
2016-11-25T23:42:31.235555000Z     raise ChunkedEncodingError(e)
2016-11-25T23:42:31.235680000Z requests.exceptions.ChunkedEncodingError: ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))
dmpettyp commented 8 years ago

Thanks for the extra info, I'll look into it

alekna commented 8 years ago

When?

dmpettyp commented 8 years ago

I'm sorry, these changes have been completed but they got caught up in a larger effort to release the spec as an OpenAPI specification. All of this should go out mid-week.

alekna commented 7 years ago

Mid-week as in today?

dmpettyp commented 7 years ago

Should be there now, thanks for you patience.