#Custum Component - blocking HA startup
1 messages · Page 1 of 1 (latest)
Does that register function exit? I see it re registers itself at the end. I guess this should be expected to be long running
It does reregister when it is done. This can happen when an update comes in or when the session is open for too long.
So I see it did finish the first subscription round and started the second one
I'm curious if not resubscribing helps as a test
Also not sure why that task wouldn't lock startup
I will give that a try indeed.
But indeed, it seems that it is really waiting until dhcp is configured / libcap.
Ok sure. You can disable defsult_config and add back the individual pieces if they is really what it is
My impression is the setting are has a list of load times per integration
The weird thing is that it only shows 12 seconds in the settings area in hA
However, it is just this branch that is blocking in my dev and prod environment. So something is not right.
Is the data subscriber task referenced anywhere once it is assigned?
I feel like it's gotta be blocking the event loop somehow
And maybe the dhcp issue is a timeout after being blocked for two minutes
(a symptom not a cause)
I will investigate, it really is related to the hass.async_create_task(_async_subscribe_for_data(hass, entry, data))
If I uncomment that one, it starts directly
@callback
def async_create_task(self, target: Awaitable[_R]) -> asyncio.Task[_R]:
"""Create a task from within the eventloop.
This method must be run in the event loop.
target: target to call.
"""
task = self.loop.create_task(target)
if self._track_task:
self._pending_tasks.append(task)
return task
I wonder if it is related to the track_task
oh _async_subscribe_for_data is not an async method
oh no im confusing it with the register method
ok so i think it makes sense..
async_block_till_done might never finish
One option is to create your own executor for running this
perhaps another is to start it after home assistant has started
i realize you need to be careful about managing shutdown
Hmm that sounds indeed like the culprit
I hoped that HA would have a function available to hook into, so that it would be disposed automatically on stop.
maybe it cancels the tasks, i'm not sure
but i suspect you'd want to do that yourself
i don't think home assistant would aggressively cancel in case you're persisting data to a database or something
The global event EVENT_HOMEASSISTANT_STARTED may be worth a try
Thanks Allen!
It's a pity that I cannot use the DataUpdateCoordinator for this, since now I would need to add my own retry logic as well.