tchellomello / python-amcrest

A Python 2.7/3.x module for Amcrest and Dahua Cameras using the SDK HTTP API.
GNU General Public License v2.0
216 stars 76 forks source link

Raise timeout exception from async stream #211

Closed flacjacket closed 2 years ago

flacjacket commented 2 years ago

Using httpx, the .stream method does not raise an exception when the device goes offline if the read timeout is disabled. To get around this, introduce a new exception that will be thrown if a timeout is hit so it can more easily be handled and the stream reconnected as needed. Add handling logic to the async_event_stream so it behaves like the non-async method by retrying while read errors are thrown.