mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 22:57:17 +00:00
Improve helpers.frame.report_usage
when called from outside the event loop (#148021)
This commit is contained in:
parent
b999c5906e
commit
bc4a322e81
@ -185,6 +185,16 @@ def report_usage(
|
|||||||
"""
|
"""
|
||||||
if (hass := _hass.hass) is None:
|
if (hass := _hass.hass) is None:
|
||||||
raise RuntimeError("Frame helper not set up")
|
raise RuntimeError("Frame helper not set up")
|
||||||
|
integration_frame: IntegrationFrame | None = None
|
||||||
|
integration_frame_err: MissingIntegrationFrame | None = None
|
||||||
|
if not integration_domain:
|
||||||
|
try:
|
||||||
|
integration_frame = get_integration_frame(
|
||||||
|
exclude_integrations=exclude_integrations
|
||||||
|
)
|
||||||
|
except MissingIntegrationFrame as err:
|
||||||
|
if core_behavior is ReportBehavior.ERROR:
|
||||||
|
integration_frame_err = err
|
||||||
_report_usage_partial = functools.partial(
|
_report_usage_partial = functools.partial(
|
||||||
_report_usage,
|
_report_usage,
|
||||||
hass,
|
hass,
|
||||||
@ -193,8 +203,9 @@ def report_usage(
|
|||||||
core_behavior=core_behavior,
|
core_behavior=core_behavior,
|
||||||
core_integration_behavior=core_integration_behavior,
|
core_integration_behavior=core_integration_behavior,
|
||||||
custom_integration_behavior=custom_integration_behavior,
|
custom_integration_behavior=custom_integration_behavior,
|
||||||
exclude_integrations=exclude_integrations,
|
|
||||||
integration_domain=integration_domain,
|
integration_domain=integration_domain,
|
||||||
|
integration_frame=integration_frame,
|
||||||
|
integration_frame_err=integration_frame_err,
|
||||||
level=level,
|
level=level,
|
||||||
)
|
)
|
||||||
if hass.loop_thread_id != threading.get_ident():
|
if hass.loop_thread_id != threading.get_ident():
|
||||||
@ -212,8 +223,9 @@ def _report_usage(
|
|||||||
core_behavior: ReportBehavior,
|
core_behavior: ReportBehavior,
|
||||||
core_integration_behavior: ReportBehavior,
|
core_integration_behavior: ReportBehavior,
|
||||||
custom_integration_behavior: ReportBehavior,
|
custom_integration_behavior: ReportBehavior,
|
||||||
exclude_integrations: set[str] | None,
|
|
||||||
integration_domain: str | None,
|
integration_domain: str | None,
|
||||||
|
integration_frame: IntegrationFrame | None,
|
||||||
|
integration_frame_err: MissingIntegrationFrame | None,
|
||||||
level: int,
|
level: int,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Report incorrect code usage.
|
"""Report incorrect code usage.
|
||||||
@ -235,12 +247,10 @@ def _report_usage(
|
|||||||
_report_usage_no_integration(what, core_behavior, breaks_in_ha_version, None)
|
_report_usage_no_integration(what, core_behavior, breaks_in_ha_version, None)
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
if not integration_frame:
|
||||||
integration_frame = get_integration_frame(
|
_report_usage_no_integration(
|
||||||
exclude_integrations=exclude_integrations
|
what, core_behavior, breaks_in_ha_version, integration_frame_err
|
||||||
)
|
)
|
||||||
except MissingIntegrationFrame as err:
|
|
||||||
_report_usage_no_integration(what, core_behavior, breaks_in_ha_version, err)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
integration_behavior = core_integration_behavior
|
integration_behavior = core_integration_behavior
|
||||||
|
Loading…
x
Reference in New Issue
Block a user