HA 2024.4.2: Non-thread-safe operation
andrewjswan opened this issue · 3 comments
andrewjswan commented
2024-04-17 02:36:14.145 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved: File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/usr/src/homeassistant/homeassistant/__main__.py", line 222, in <module>
sys.exit(main())
File "/usr/src/homeassistant/homeassistant/__main__.py", line 210, in main
exit_code = runner.run(runtime_conf)
File "/usr/src/homeassistant/homeassistant/runner.py", line 189, in run
return loop.run_until_complete(setup_and_run_hass(runtime_config))
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 672, in run_until_complete
self.run_forever()
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 639, in run_forever
self._run_once()
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1980, in _run_once
handle._run()
File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "/config/custom_components/blitzortung/mqtt.py", line 284, in _mqtt_handle_message
self.hass.async_run_job(
File "/usr/src/homeassistant/homeassistant/core.py", line 896, in async_run_job
return self.async_run_hass_job(HassJob(target), *args)
File "/usr/src/homeassistant/homeassistant/core.py", line 840, in async_run_hass_job
return self.async_add_hass_job(
File "/usr/src/homeassistant/homeassistant/core.py", line 695, in async_add_hass_job
task = self.loop.run_in_executor(None, hassjob.target, *args)
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 860, in run_in_executor
return futures.wrap_future(
File "/usr/local/lib/python3.12/asyncio/futures.py", line 417, in wrap_future
new_future = loop.create_future()
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 448, in create_future
return futures.Future(loop=self)
Traceback (most recent call last):
File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/blitzortung/__init__.py", line 304, in on_mqtt_message
sensor.update_lightning(lightning)
File "/config/custom_components/blitzortung/sensor.py", line 162, in update_lightning
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 998, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1181, in _async_write_ha_state
hass.states.async_set(
File "/usr/src/homeassistant/homeassistant/core.py", line 2181, in async_set
self._bus._async_fire( # pylint: disable=protected-access
File "/usr/src/homeassistant/homeassistant/core.py", line 1459, in _async_fire
self._hass.async_add_hass_job(job, event)
File "/usr/src/homeassistant/homeassistant/core.py", line 690, in async_add_hass_job
self.loop.call_soon(hassjob.target, *args)
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 795, in call_soon
self._check_thread()
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 832, in _check_thread
raise RuntimeError(
RuntimeError: Non-thread-safe operation invoked on an event loop other than the current one
andrewjswan commented
2024-04-17 02:36:14.880 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved: File "/usr/local/lib/python3.12/threading.py", line 1030, in _bootstrap
self._bootstrap_inner()
File "/usr/local/lib/python3.12/threading.py", line 1073, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.12/threading.py", line 1010, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 92, in _worker
work_item.run()
File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/blitzortung/__init__.py", line 302, in on_mqtt_message
callback(lightning)
File "/config/custom_components/blitzortung/geo_location.py", line 117, in lightning_cb
self._async_add_entities([event])
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 495, in _async_schedule_add_entities_for_entry
task = self.config_entry.async_create_task(
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1029, in async_create_task
task = hass.async_create_task(
File "/usr/src/homeassistant/homeassistant/core.py", line 729, in async_create_task
task = create_eager_task(target, name=name, loop=self.loop)
File "/usr/src/homeassistant/homeassistant/util/async_.py", line 33, in create_eager_task
return Task(
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 629, in async_add_entities
await add_func(coros, entities, timeout)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 577, in _async_add_entities
async with self.hass.timeout.async_timeout(timeout, self.domain):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/util/timeout.py", line 470, in async_timeout
current_task: asyncio.Task[Any] | None = asyncio.current_task()
^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: no running event loop
2024-04-17 02:36:14.881 WARNING (MainThread) [py.warnings] /usr/src/homeassistant/homeassistant/helpers/trace.py:143: RuntimeWarning: coroutine 'EntityPlatform._async_add_entity' was never awaited
trace_stack_var.set(trace_stack)
andrewjswan commented
2024-04-17 03:00:59.373 ERROR (SyncWorker_4) [homeassistant.util.logging] Exception in _on_connection_change when dispatching 'blitzortung_mqtt_connected': ()
Traceback (most recent call last):
File "/config/custom_components/blitzortung/__init__.py", line 225, in _on_connection_change
sensor.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 998, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1181, in _async_write_ha_state
hass.states.async_set(
File "/usr/src/homeassistant/homeassistant/core.py", line 2181, in async_set
self._bus._async_fire( # pylint: disable=protected-access
File "/usr/src/homeassistant/homeassistant/core.py", line 1459, in _async_fire
self._hass.async_add_hass_job(job, event)
File "/usr/src/homeassistant/homeassistant/core.py", line 690, in async_add_hass_job
self.loop.call_soon(hassjob.target, *args)
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 795, in call_soon
self._check_thread()
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 832, in _check_thread
raise RuntimeError(
RuntimeError: Non-thread-safe operation invoked on an event loop other than the current one