Hi
running HA 2022.7.5 in a Python venv, Python 3.9, Raspberry Pi 4, 4GB, Storage on SSD
Once in a while I have this message in the log:
2022-08-02 04:50:05 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/srv/homeassistant2/lib/python3.9/site-packages/homeassistant/data_entry_flow.py", line 222, in async_init
flow, result = await task
File "/srv/homeassistant2/lib/python3.9/site-packages/homeassistant/data_entry_flow.py", line 249, in _async_init
result = await self._async_handle_step(flow, flow.init_step, data, init_done)
File "/srv/homeassistant2/lib/python3.9/site-packages/homeassistant/data_entry_flow.py", line 359, in _async_handle_step
result: FlowResult = await getattr(flow, method)(user_input)
File "/home/homeassistant/.homeassistant/custom_components/bosch_shc/config_flow.py", line 193, in async_step_zeroconf
self.info = await self._get_info(discovery_info.host)
File "/home/homeassistant/.homeassistant/custom_components/bosch_shc/config_flow.py", line 225, in _get_info
return await self.hass.async_add_executor_job(
File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/homeassistant/.homeassistant/custom_components/bosch_shc/config_flow.py", line 74, in get_info_from_host
information = session.mdns_info()
File "/srv/homeassistant2/lib/python3.9/site-packages/boschshcpy/session.py", line 277, in mdns_info
return SHCInformation(
File "/srv/homeassistant2/lib/python3.9/site-packages/boschshcpy/information.py", line 80, in __init__
self.get_unique_id(zeroconf)
File "/srv/homeassistant2/lib/python3.9/site-packages/boschshcpy/information.py", line 138, in get_unique_id
self._listener = SHCListener(zeroconf, self.filter)
File "/srv/homeassistant2/lib/python3.9/site-packages/boschshcpy/information.py", line 32, in __init__
ServiceBrowser(zeroconf, "_http._tcp.local.", handlers=[self.service_update])
File "/srv/homeassistant2/lib/python3.9/site-packages/zeroconf/_services/browser.py", line 511, in __init__
self.start()
File "/usr/lib/python3.9/threading.py", line 874, in start
_start_new_thread(self._bootstrap, ())
RuntimeError: can't start new thread
at around 04:50am BoschSHC integration could not start a new thread.
This time I monitored the system since restarting on 2022-07-28 17:50. Did install py-spy and found this:
I have an ever increasing number of threads with this name:
Thread 0xBE80E440 (active): “zeroconf-ServiceBrowser-_http._tcp-2954”
After starting the HA-Service I have 3 such threads and it increases by 2 threads every 40-50 minutes, the maximum was 312 “zeroconf-ServiceBrowser-_http._tcp-”-Threads this morning at 04:50, same time I had the error above in the logs. Setup a sensor for monitoring
- platform: command_line
name: ThreadWatch1
command: "py-spy dump --pid $(pgrep -u homeassistant hass ) |grep zeroconf-ServiceBrowser-_http._tcp | wc -l"
Stacktrace for all 312 threads is similar:
Thread 0xBE80E440 (active): "zeroconf-ServiceBrowser-_http._tcp-2954"
run (zeroconf/_services/browser.py:530)
Arguments:
self: <ServiceBrowser at 0x6f1db328>
Locals:
event: (("ds416._http._tcp.local.", "_http._tcp.local."), <ServiceStateChange at 0xae016178>)
_bootstrap_inner (threading.py:954)
Arguments:
self: <ServiceBrowser at 0x6f1db328>
_bootstrap (threading.py:912)
Arguments:
self: <ServiceBrowser at 0x6f1db328>
First suspect was the custom component for BoschSHC, but I disabled the integration and the number of threads was still increasing after a restart
Another suspect was my Synology DS416 because the name was listed in the stacktrace. The Synology is also acting as DHCP- and DNS-Server in my network.
Also disabled the Synology integration, number of threads was still increasing
Any idea what causes the threads being started and obviously never terminated?
Armin