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

"Passing coroutines is forbidden, use tasks explicitly" - Python incompatibility? #46

Open
maks23rus opened this issue Nov 17, 2023 · 0 comments

Comments

@maks23rus
Copy link

The services still work, but every time one is executed the error appears.

I've noticied some problems related with "async", in other custom components, and the new changes with Python...

Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:230
Integration: Home Assistant WebSocket API ([documentation](https://www.home-assistant.io/integrations/websocket_api), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+websocket_api%22))
First occurred: 11:21:16 (1 occurrences)
Last logged: 11:21:16

[140322262907200] Passing coroutines is forbidden, use tasks explicitly.
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 230, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 2035, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2072, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/miio2/vacuum.py", line 231, in async_service_handler
    await asyncio.wait(update_tasks)
  File "/usr/local/lib/python3.11/asyncio/tasks.py", line 425, in wait
    raise TypeError("Passing coroutines is forbidden, use tasks explicitly.")
TypeError: Passing coroutines is forbidden, use tasks explicitly.

Please change the code to:

for vacuum in target_vacuums:
    update_coro = vacuum.async_update_ha_state(True)
    update_tasks.append(asyncio.create_task(update_coro))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant