Integration: 0.20.x: cannot reuse already awaited coroutine

Created on 15 Jan 2020  路  15Comments  路  Source: hacs/integration


Version of HACS

0.20.x

Describe the bug

HACS doesn't allow to install or update anything. Buttons Install/Update are grayed. All the time progress bar shows update data from GitHub and every 30 minutes I have error in log. This state persists for several days.

Debug log

2020-01-15 11:57:13 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/home/homeassistant/.homeassistant/custom_components/hacs/hacsbase/__init__.py", line 304, in recuring_tasks_installed
    await self.factory.execute()
  File "/home/homeassistant/.homeassistant/custom_components/hacs/hacsbase/task_factory.py", line 24, in execute
    await asyncio.gather(*self.tasks)
RuntimeError: cannot reuse already awaited coroutine
Bug

Most helpful comment

Same error, 0.104.2, latest HACS. Restart helps but problem reappeares.

All 15 comments

Make sure you have read the issue guidelines and that you filled out the entire template.

Restart Home Assistant

I'll do that when I come back home.

After HA restart everything is normal.

After few days without restart and issue returns.
HACS 0.20.8

Same error, 0.104.2, latest HACS. Restart helps but problem reappeares.

Same issue for me:
image

Exactly the same error for me too.

It seems that it is happening consistently at exactly 30min intervals

Same issue here, random continuous loading preventing me from taking any actions. However, restarting HA or HassOS does not resolve the issue unfortunately.

I've looked at the code, and my understanding is that the task factory is called on different schedules to run various sets of background tasks (getting data for installed repositories, getting data for all repositories, etc.).
As these use all use the same instance of the task factory, if two of the schedules happen to overlap (e.g. refreshing all repositories at the same time as installed repositories), it may end up trying to await one or more tasks which have already completed which would result in the "cannot reuse already awaited coroutine" error.

Would the solution in this case be to either have multiple task factory instances or to not allow the task factory to execute background tasks if they are already running?

That is correct @gadgetchnnel.

The taskfactory should have exception handling

I have the same issue :/
Are You working on some solution?

Home Assistant 0.104.2.
hacs 0.20.8

today again the same issue...

+1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

robross0606 picture robross0606  路  5Comments

Tamas-Toth-ebola picture Tamas-Toth-ebola  路  6Comments

lbouriez picture lbouriez  路  6Comments

SeanPM5 picture SeanPM5  路  6Comments

JPM-git picture JPM-git  路  8Comments