PTST / O365-HomeAssistant

Office 365 integration for Home Assistant
MIT License
69 stars 13 forks source link

0.109 reports blocking I/O in the event loop #57

Closed mdegat01 closed 4 years ago

mdegat01 commented 4 years ago

Just updated to 0.109 and found this issue in my log Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for o365 doing I/O at custom_components/o365/calendar.py, line 158: limit=self.limit, query=query, include_recurring=True

In the release notes of 0.109 (as well as the log) HA team asks any instance of this log entry be reported as an issue on the component.

jrnhrmn commented 4 years ago

Same here

RogerSelwyn commented 4 years ago

and me, every 15 mins

RogerSelwyn commented 4 years ago

I notice the setup in init.py isn't configured as async, (I think it should be async def async_setup...), but changing that didn't resolve the problem. So I think the issue is somewhere in the O365 module, which I'll try and do some debug against later. Not sure if it isn't just the fact of a problem with the way O365 queries work...

PTST commented 4 years ago

Last i checked the O365 module was not async at all.

I will investigate when i have the time. But considering my daughter just arrived in the world, i honestly do not know when that will be

RogerSelwyn commented 4 years ago

I'm planning to take a look. On the asynchronous subject, a number of methods in calendar.py are marked as async, and they seem to get called. Just seems the setup routine isn't async, not sure if it matters. I keep having to google what is achievable, so not sure if I can tell if the thing that is erroring it is actually async or not, I think it gets called from a couple of places. Just spending quality time with family who are off work, whilst I am still full time at my desk.

RogerSelwyn commented 4 years ago

I will investigate when i have the time. But considering my daughter just arrived in the world, i honestly do not know when that will be

Congratulations by the way. Sleepless nights ahead, so I understand...

RogerSelwyn commented 4 years ago

I think the problem is that the calls to O365 are from inside an async routine, but possibly O365 is not async friendly. So I think you need to call them via a hass helper async_create_task as shown here https://developers.home-assistant.io/docs/asyncio_working_with_async. Not sure how many others items may need to be changed like that, I'm only using calendar.

Assuming you don't look at this overnight, I'll try to have a look tomorrow morning.

unbreakmat commented 4 years ago

2020-05-08 16:26:10 WARNING (MainThread) [homeassistant.util.async_] Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for o365 doing I/O at custom_components/o365/calendar.py, line 158: limit=self.limit, query=query, include_recurring=True

same problem here