spacemanspiff2007 / HABApp

Easy home automation with MQTT and/or openHAB
Apache License 2.0
54 stars 23 forks source link

Logs full of exceptions after upgrading to 1.0.7 pypi #362

Closed lorenzodeveloper closed 1 year ago

lorenzodeveloper commented 1 year ago

Hi, Just upgraded to 1.0.7 from 1.0.6 on pipy. First issue: habapp wasn't connecting due to missing credentials: I had to change from API token to basic auth. Is the API token auth deprecated for habapp? Second issue: After I changed the connection credentials from token to basic, it started working again, but now my logs are full of exceptions:

2023-02-09 09:46:51.744 [ERROR] [HABApp.openhab.connection           ] - Error Task <Task pending name='OhQueue' coro=<SingleTask._task_wrap() running at /opt/habapp/lib/python3.8/site-packages/HABApp/core/lib/single_task.py:27> created at /usr/lib/python3.8/asyncio/tasks.py:382> got Future <Future pending> attached to a different loop in output_queue_listener:
2023-02-09 09:46:51.744 [ERROR] [HABApp.openhab.connection           ] - File "/usr/lib/python3.8/asyncio/queues.py", line 163 in get
2023-02-09 09:46:51.745 [ERROR] [HABApp.openhab.connection           ] - --------------------------------------------------------------------------------
2023-02-09 09:46:51.745 [ERROR] [HABApp.openhab.connection           ] -      154 | async def get(self):
2023-02-09 09:46:51.745 [ERROR] [HABApp.openhab.connection           ] -        (...)
2023-02-09 09:46:51.746 [ERROR] [HABApp.openhab.connection           ] -      160 |         getter = self._loop.create_future()
2023-02-09 09:46:51.746 [ERROR] [HABApp.openhab.connection           ] -      161 |         self._getters.append(getter)
2023-02-09 09:46:51.746 [ERROR] [HABApp.openhab.connection           ] -      162 |         try:
2023-02-09 09:46:51.746 [ERROR] [HABApp.openhab.connection           ] - -->  163 |             await getter
2023-02-09 09:46:51.747 [ERROR] [HABApp.openhab.connection           ] -      164 |         except:
2023-02-09 09:46:51.747 [ERROR] [HABApp.openhab.connection           ] -    ------------------------------------------------------------
2023-02-09 09:46:51.747 [ERROR] [HABApp.openhab.connection           ] -      self = <Queue at 0x7f7f9d65b0 maxsize=0 tasks=26>
2023-02-09 09:46:51.748 [ERROR] [HABApp.openhab.connection           ] -      self._getters = deque([])
2023-02-09 09:46:51.748 [ERROR] [HABApp.openhab.connection           ] -      self._loop = <_UnixSelectorEventLoop running=False closed=False debug=False>
2023-02-09 09:46:51.748 [ERROR] [HABApp.openhab.connection           ] -      getter = <Future cancelled>
2023-02-09 09:46:51.748 [ERROR] [HABApp.openhab.connection           ] -    ------------------------------------------------------------
2023-02-09 09:46:51.749 [ERROR] [HABApp.openhab.connection           ] -
2023-02-09 09:46:51.749 [ERROR] [HABApp.openhab.connection           ] - --------------------------------------------------------------------------------
2023-02-09 09:46:51.749 [ERROR] [HABApp.openhab.connection           ] - Traceback (most recent call last):
2023-02-09 09:46:51.750 [ERROR] [HABApp.openhab.connection           ] -   File "/opt/habapp/lib/python3.8/site-packages/HABApp/openhab/connection_handler/http_connection.py", line 282, in output_queue_listener
2023-02-09 09:46:51.750 [ERROR] [HABApp.openhab.connection           ] -     item, state, is_cmd = await QUEUE.get()
2023-02-09 09:46:51.750 [ERROR] [HABApp.openhab.connection           ] -   File "/usr/lib/python3.8/asyncio/queues.py", line 163, in get
2023-02-09 09:46:51.750 [ERROR] [HABApp.openhab.connection           ] -     await getter
2023-02-09 09:46:51.751 [ERROR] [HABApp.openhab.connection           ] - RuntimeError: Task <Task pending name='OhQueue' coro=<SingleTask._task_wrap() running at /opt/habapp/lib/python3.8/site-packages/HABApp/core/lib/single_task.py:27> created at /usr/lib/python3.8/asyncio/tasks.py:382> got Future <Future pending> attached to a different loop
2023-02-09 09:46:51.762 [ERROR] [HABApp.openhab.connection           ] - Error Task <Task pending name='OhQueue' coro=<SingleTask._task_wrap() running at /opt/habapp/lib/python3.8/site-packages/HABApp/core/lib/single_task.py:27> created at /usr/lib/python3.8/asyncio/tasks.py:382> got Future <Future pending> attached to a different loop in output_queue_listener:
2023-02-09 09:46:51.762 [ERROR] [HABApp.openhab.connection           ] - File "/usr/lib/python3.8/asyncio/queues.py", line 163 in get
2023-02-09 09:46:51.762 [ERROR] [HABApp.openhab.connection           ] - --------------------------------------------------------------------------------
2023-02-09 09:46:51.762 [ERROR] [HABApp.openhab.connection           ] -      154 | async def get(self):
2023-02-09 09:46:51.762 [ERROR] [HABApp.openhab.connection           ] -        (...)
2023-02-09 09:46:51.763 [ERROR] [HABApp.openhab.connection           ] -      160 |         getter = self._loop.create_future()
2023-02-09 09:46:51.763 [ERROR] [HABApp.openhab.connection           ] -      161 |         self._getters.append(getter)
2023-02-09 09:46:51.763 [ERROR] [HABApp.openhab.connection           ] -      162 |         try:
2023-02-09 09:46:51.763 [ERROR] [HABApp.openhab.connection           ] - -->  163 |             await getter
2023-02-09 09:46:51.763 [ERROR] [HABApp.openhab.connection           ] -      164 |         except:
2023-02-09 09:46:51.763 [ERROR] [HABApp.openhab.connection           ] -    ------------------------------------------------------------
2023-02-09 09:46:51.763 [ERROR] [HABApp.openhab.connection           ] -      self = <Queue at 0x7f7f9d65b0 maxsize=0 tasks=26>
2023-02-09 09:46:51.764 [ERROR] [HABApp.openhab.connection           ] -      self._getters = deque([])
2023-02-09 09:46:51.764 [ERROR] [HABApp.openhab.connection           ] -      self._loop = <_UnixSelectorEventLoop running=False closed=False debug=False>
2023-02-09 09:46:51.764 [ERROR] [HABApp.openhab.connection           ] -      getter = <Future cancelled>
2023-02-09 09:46:51.764 [ERROR] [HABApp.openhab.connection           ] -    ------------------------------------------------------------
2023-02-09 09:46:51.764 [ERROR] [HABApp.openhab.connection           ] -
2023-02-09 09:46:51.764 [ERROR] [HABApp.openhab.connection           ] - --------------------------------------------------------------------------------
2023-02-09 09:46:51.764 [ERROR] [HABApp.openhab.connection           ] - Traceback (most recent call last):
2023-02-09 09:46:51.764 [ERROR] [HABApp.openhab.connection           ] -   File "/opt/habapp/lib/python3.8/site-packages/HABApp/openhab/connection_handler/http_connection.py", line 282, in output_queue_listener
2023-02-09 09:46:51.765 [ERROR] [HABApp.openhab.connection           ] -     item, state, is_cmd = await QUEUE.get()
2023-02-09 09:46:51.765 [ERROR] [HABApp.openhab.connection           ] -   File "/usr/lib/python3.8/asyncio/queues.py", line 163, in get
2023-02-09 09:46:51.765 [ERROR] [HABApp.openhab.connection           ] -     await getter
2023-02-09 09:46:51.765 [ERROR] [HABApp.openhab.connection           ] - RuntimeError: Task <Task pending name='OhQueue' coro=<SingleTask._task_wrap() running at /opt/habapp/lib/python3.8/site-packages/HABApp/core/lib/single_task.py:27> created at /usr/lib/python3.8/asyncio/tasks.py:382> got Future <Future pending> attached to a different loop
2023-02-09 09:46:51.775 [ERROR] [HABApp.openhab.connection           ] - Error Task <Task pending name='OhQueue' coro=<SingleTask._task_wrap() running at /opt/habapp/lib/python3.8/site-packages/HABApp/core/lib/single_task.py:27> created at /usr/lib/python3.8/asyncio/tasks.py:382> got Future <Future pending> attached to a different loop in output_queue_listener:
2023-02-09 09:46:51.776 [ERROR] [HABApp.openhab.connection           ] - File "/usr/lib/python3.8/asyncio/queues.py", line 163 in get
2023-02-09 09:46:51.776 [ERROR] [HABApp.openhab.connection           ] - --------------------------------------------------------------------------------
2023-02-09 09:46:51.776 [ERROR] [HABApp.openhab.connection           ] -      154 | async def get(self):
2023-02-09 09:46:51.776 [ERROR] [HABApp.openhab.connection           ] -        (...)
2023-02-09 09:46:51.776 [ERROR] [HABApp.openhab.connection           ] -      160 |         getter = self._loop.create_future()
2023-02-09 09:46:51.776 [ERROR] [HABApp.openhab.connection           ] -      161 |         self._getters.append(getter)
2023-02-09 09:46:51.776 [ERROR] [HABApp.openhab.connection           ] -      162 |         try:
2023-02-09 09:46:51.777 [ERROR] [HABApp.openhab.connection           ] - -->  163 |             await getter
2023-02-09 09:46:51.777 [ERROR] [HABApp.openhab.connection           ] -      164 |         except:
2023-02-09 09:46:51.777 [ERROR] [HABApp.openhab.connection           ] -    ------------------------------------------------------------
2023-02-09 09:46:51.777 [ERROR] [HABApp.openhab.connection           ] -      self = <Queue at 0x7f7f9d65b0 maxsize=0 tasks=26>
2023-02-09 09:46:51.777 [ERROR] [HABApp.openhab.connection           ] -      self._getters = deque([])
2023-02-09 09:46:51.777 [ERROR] [HABApp.openhab.connection           ] -      self._loop = <_UnixSelectorEventLoop running=False closed=False debug=False>
2023-02-09 09:46:51.777 [ERROR] [HABApp.openhab.connection           ] -      getter = <Future cancelled>
2023-02-09 09:46:51.777 [ERROR] [HABApp.openhab.connection           ] -    ------------------------------------------------------------
2023-02-09 09:46:51.777 [ERROR] [HABApp.openhab.connection           ] -
2023-02-09 09:46:51.778 [ERROR] [HABApp.openhab.connection           ] - --------------------------------------------------------------------------------
2023-02-09 09:46:51.778 [ERROR] [HABApp.openhab.connection           ] - Traceback (most recent call last):
2023-02-09 09:46:51.778 [ERROR] [HABApp.openhab.connection           ] -   File "/opt/habapp/lib/python3.8/site-packages/HABApp/openhab/connection_handler/http_connection.py", line 282, in output_queue_listener
2023-02-09 09:46:51.778 [ERROR] [HABApp.openhab.connection           ] -     item, state, is_cmd = await QUEUE.get()
2023-02-09 09:46:51.778 [ERROR] [HABApp.openhab.connection           ] -   File "/usr/lib/python3.8/asyncio/queues.py", line 163, in get
2023-02-09 09:46:51.778 [ERROR] [HABApp.openhab.connection           ] -     await getter
2023-02-09 09:46:51.778 [ERROR] [HABApp.openhab.connection           ] - RuntimeError: Task <Task pending name='OhQueue' coro=<SingleTask._task_wrap() running at /opt/habapp/lib/python3.8/site-packages/HABApp/core/lib/single_task.py:27> created at /usr/lib/python3.8/asyncio/tasks.py:382> got Future <Future pending> attached to a different loop

What can I do? Is it something wrong with my environment? Thank you.

Currently using python 3.8.13 on RPI4

Lorenzo

spacemanspiff2007 commented 1 year ago

Does a restart fix the issue?

spacemanspiff2007 commented 1 year ago

First issue: habapp wasn't connecting due to missing credentials: I had to change from API token to basic auth. Is the API token auth deprecated for habapp?

Ah - I might have introduced this while checking for username/password. 👎 How have you passed the token before? Just as username or just as password?

What can I do? Is it something wrong with my environment?

Does a restart fix the issue?

lorenzodeveloper commented 1 year ago

Does a restart fix the issue?

Already tried, both habapp service restart and system restart, but still the issue persists :(

How have you passed the token before? Just as username or just as password? Before I was passing the token as username and password was empty.

Example

openhab:
  connection:
    url: ...
    user: oh.<token-name>.<token>
    password : ''
spacemanspiff2007 commented 1 year ago

Hm - very strange! I can't reproduce the issue and in the 1.0.7 release I haven't changed anything related to asyncio! 😕 I tried something in this branch, could you try it out?

lorenzodeveloper commented 1 year ago

The branch solved the issue on token, but still I have the exceptions. I tried upgrading the asyncio library, but seems to be already up to date, do you have any list of library that may be impacting habapp? I can try upgrade them in case.

spacemanspiff2007 commented 1 year ago

I've made another attempt. Could you try again? Sorry for the back and forth, but I can't reproduce the issue (I'm already on python3.10)

lorenzodeveloper commented 1 year ago

No problem! Thanks for your prompt help!

So far it looks good. No exceptions at all. What was the issue? Thank you very much!

spacemanspiff2007 commented 1 year ago

grafik

spacemanspiff2007 commented 1 year ago

Fixed in 1.0.8 - thanks for the report