ol-iver / denonavr

Automation Library for Denon AVR receivers.
MIT License
176 stars 67 forks source link

Fix connectivity issues #174

Closed JPHutchins closed 3 years ago

JPHutchins commented 3 years ago

See https://github.com/home-assistant/core/issues/43670 and elsewhere.

I was wrong about race conditions. However, if _get_receiver_sources fails it was mutating the self._receiver_type which caused lots of other requests to fail, timeout 403 etc.

Still not sure why receivers were actually "locking up" - could not recreate even sending batches of 2000 updates with 50 in parallel. However, during big requests I was able to observe the device info endpoint request time rising from 8ms to 3.3s

We may want to revisit ensure_configuration since it still does have a lot of blocking IO that HA doesn't like.

ol-iver commented 3 years ago

@JPHutchins this change as probably only little effect, because _get_receiver_sources is only called when the current input function is not found in _input_func_list or when it is not existing at all.

I don't understand your point regarding ensure_configuration. It is just performing HTTP requests when there are missing configuration parameter. This is usually only the case when an instance is created. Additionally it is only called from update method which is exactly the place HA is expecting blocking calls.

Anyhow your change sounds reasonable 😄