Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected error fetching omnik_inverter data: coroutine ignored GeneratorExit #116

Closed
serrj-sv opened this issue Jun 9, 2022 · 8 comments · Fixed by klaasnicolaas/python-omnikinverter#339
Labels
no-stale This issue or PR is exempted from the stable bot.

Comments

@serrj-sv
Copy link

serrj-sv commented Jun 9, 2022

I get this error every now and then since switching to TCP mode for my Omnik 3000TL:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 191, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/omnik_inverter/__init__.py", line 125, in _async_update_data
    SERVICE_INVERTER: await self.omnikinverter.inverter(),
  File "/usr/local/lib/python3.9/site-packages/omnikinverter/omnikinverter.py", line 186, in inverter
    fields = await self.tcp_request()
RuntimeError: coroutine ignored GeneratorExit
@serrj-sv
Copy link
Author

serrj-sv commented Jun 9, 2022

I was able to mitigate it by adding async with async_timeout.timeout(10): at line 126 as per official HA documentation:
https://developers.home-assistant.io/docs/integration_fetching_data/

@MarijnS95
Copy link
Collaborator

I've also seen this RuntimeError GeneratorExit error a couple times, but don't yet understand where it comes from. I'd argue a timeout in the underlying socket would bubble up as TimeoutError, but that doesn't seem the case (or this is a different kind of error).

Perhaps this workaround makes the async backend timeout before that RuntimeError is raised; and as mentioned by that comment it seems HA gracefully handles a TimeoutError without spamming logs full.

@klaasnicolaas pointed out that this is also done for the other (JS/HTML) data sources:

https://github.com/klaasnicolaas/python-omnikinverter/blob/6173f341ad4266b1674a3fb6879e792c6cdd3c07/omnikinverter/omnikinverter.py#L89

We should probably quickly release a followup that adds this to the TCP backend, but I'd like to get the conversion from poll to push over with sooner rather than later (where this is handled differently or not at all).

Thanks for testing out the new TCP backend though! While I don't like it, it's technically still early days and bugs have to be fully ironed out 🤞

MarijnS95 added a commit to MarijnS95/python-omnikinverter that referenced this issue Jun 11, 2022
There have recently been [reports of `RuntimeError: coroutine ignored
GeneratorExit`] which are presumably triggered by timeouts on the
socket, without being raised as `TimeoutError`.  This case seems to be
mitigated by timing out the request after a default of 10 seconds which
doesn't give `GeneratorExit` - triggered by something yet unknown -
enough time to surface.

[reports of `RuntimeError: coroutine ignored GeneratorExit`]: robbinjanssen/home-assistant-omnik-inverter#116
@MarijnS95
Copy link
Collaborator

MarijnS95 commented Jun 11, 2022

This mitigation is now up in klaasnicolaas/python-omnikinverter#207, still unsure where the error is coming from...

Fwiw the HTML/JS code re-wraps this exception as OmnikInverterConnectionError, so I'm not sure if HASS gracefully deals with it and tries again later or spams logs full again; I'll have to test it while my inverter is on during the day :)

@github-actions
Copy link

There hasn't been any activity on this issue recently, so we clean up some of the older and inactive issues.
Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thanks!

@github-actions github-actions bot added the stale label Jun 26, 2022
@github-actions github-actions bot closed this as completed Jul 4, 2022
@robbinjanssen robbinjanssen reopened this Jul 5, 2022
MarijnS95 added a commit to MarijnS95/python-omnikinverter that referenced this issue Sep 30, 2022
There have recently been [reports of `RuntimeError: coroutine ignored
GeneratorExit`] which are presumably triggered by timeouts on the
socket, without being raised as `TimeoutError`.  This case seems to be
mitigated by timing out the request after a default of 10 seconds which
doesn't give `GeneratorExit` - triggered by something yet unknown -
enough time to surface.

[reports of `RuntimeError: coroutine ignored GeneratorExit`]: robbinjanssen/home-assistant-omnik-inverter#116
MarijnS95 added a commit to MarijnS95/python-omnikinverter that referenced this issue Sep 30, 2022
There have recently been [reports of `RuntimeError: coroutine ignored
GeneratorExit`] which are presumably triggered by timeouts on the
socket, without being raised as `TimeoutError`.  This case seems to be
mitigated by timing out the request after a default of 10 seconds which
doesn't give `GeneratorExit` - triggered by something yet unknown -
enough time to surface.

[reports of `RuntimeError: coroutine ignored GeneratorExit`]: robbinjanssen/home-assistant-omnik-inverter#116
MarijnS95 added a commit to MarijnS95/python-omnikinverter that referenced this issue Sep 30, 2022
There have recently been [reports of `RuntimeError: coroutine ignored
GeneratorExit`] which are presumably triggered by timeouts on the
socket, without being raised as `TimeoutError`.  This case seems to be
mitigated by timing out the request after a default of 10 seconds which
doesn't give `GeneratorExit` - triggered by something yet unknown -
enough time to surface.

[reports of `RuntimeError: coroutine ignored GeneratorExit`]: robbinjanssen/home-assistant-omnik-inverter#116
MarijnS95 added a commit to MarijnS95/python-omnikinverter that referenced this issue Sep 30, 2022
There have recently been [reports of `RuntimeError: coroutine ignored
GeneratorExit`] which are presumably triggered by timeouts on the
socket, without being raised as `TimeoutError`.  This case seems to be
mitigated by timing out the request after a default of 10 seconds which
doesn't give `GeneratorExit` - triggered by something yet unknown -
enough time to surface.

[reports of `RuntimeError: coroutine ignored GeneratorExit`]: robbinjanssen/home-assistant-omnik-inverter#116
@ianfretwell
Copy link

Is there a fix for this actually applied? I'm running HA 2023.2 and still getting this same error (149 times since installing 2023.2 yesterday).

@MarijnS95
Copy link
Collaborator

Nope.

@ianfretwell
Copy link

Fair enough!

@github-actions github-actions bot removed the no-stale label Feb 13, 2023
MarijnS95 added a commit to MarijnS95/python-omnikinverter that referenced this issue Feb 18, 2023
There have recently been [reports of `RuntimeError: coroutine ignored
GeneratorExit`] which are presumably triggered by timeouts on the
socket, without being raised as `TimeoutError`.  This case seems to be
mitigated by timing out the request after a default of 10 seconds which
doesn't give `GeneratorExit` - triggered by something yet unknown -
enough time to surface.

[reports of `RuntimeError: coroutine ignored GeneratorExit`]: robbinjanssen/home-assistant-omnik-inverter#116
MarijnS95 added a commit to MarijnS95/python-omnikinverter that referenced this issue Feb 18, 2023
There have recently been [reports of `RuntimeError: coroutine ignored
GeneratorExit`] which are presumably triggered by timeouts on the
socket, without being raised as `TimeoutError`.  This case seems to be
mitigated by timing out the request after a default of 10 seconds which
doesn't give `GeneratorExit` - triggered by something yet unknown -
enough time to surface.

[reports of `RuntimeError: coroutine ignored GeneratorExit`]: robbinjanssen/home-assistant-omnik-inverter#116
@github-actions
Copy link

There hasn't been any activity on this issue recently, so we clean up some of the older and inactive issues.
Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thanks!

@github-actions github-actions bot added the stale There has not been activity on this issue or PR for quite some time. label Mar 16, 2023
@robbinjanssen robbinjanssen added no-stale This issue or PR is exempted from the stable bot. and removed stale There has not been activity on this issue or PR for quite some time. labels Mar 16, 2023
MarijnS95 added a commit to MarijnS95/python-omnikinverter that referenced this issue Apr 10, 2023
There have recently been [reports of `RuntimeError: coroutine ignored
GeneratorExit`] which are presumably triggered by timeouts on the
socket, without being raised as `TimeoutError`.  This case seems to be
mitigated by timing out the request after a default of 10 seconds which
doesn't give `GeneratorExit` - triggered by something yet unknown -
enough time to surface.

[reports of `RuntimeError: coroutine ignored GeneratorExit`]: robbinjanssen/home-assistant-omnik-inverter#116
klaasnicolaas pushed a commit to klaasnicolaas/python-omnikinverter that referenced this issue May 29, 2023
There have recently been [reports of `RuntimeError: coroutine ignored
GeneratorExit`] which are presumably triggered by timeouts on the
socket, without being raised as `TimeoutError`.  This case seems to be
mitigated by timing out the request after a default of 10 seconds which
doesn't give `GeneratorExit` - triggered by something yet unknown -
enough time to surface.

[reports of `RuntimeError: coroutine ignored GeneratorExit`]: robbinjanssen/home-assistant-omnik-inverter#116
@github-actions github-actions bot locked and limited conversation to collaborators Jun 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
no-stale This issue or PR is exempted from the stable bot.
Projects
None yet
4 participants