0

I am creating an app using python zeroconf, asyncio.TaskGroup and aoimqtt. I get the following error:

Exception caught: Task <Task pending name='Task-102' coro=<ServiceInfo.async_request() running at src/zeroconf/_services/info.py:None> cb=[gather.<locals>._done_callback() at /(...)/.pyenv/versions/3.12.0/lib/python3.12/asyncio/tasks.py:757]> got Future <Future pending> attached to a different loop

which is not present in another similar app, using the same zeroconf-related code, that is not using asyncio.TaskGroup.

My understanding is, that the error is related to clash between event loops. I haven't seen a way to force zeroconf to use running event loop.

Any ideas how to solve the error above are welcome.

Thanks!

2
  • Maybe you are looking for this: python-zeroconf.readthedocs.io/en/latest/…
    – VPfB
    Commented Jun 7 at 14:57
  • @VPfB Thanks. It turned out, that problem was not directly related to taskGroup or zeroconf. The difference between working and not working app was that our driver using zeroconf in working case was created in function passed to asyncio.run() and in non-working was create before and injected into main app. Apparently that caused different event loops. Changed get_event_loop to get_running_loop inside the driver helped for some reason. Commented Jun 8 at 17:51

0

Browse other questions tagged or ask your own question.