Make util.async_.protect_loop name names (#65493)

This commit is contained in:
Erik Montnemery 2022-02-03 14:06:40 +01:00 committed by GitHub
parent 3e0856ccac
commit 63680f0b36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 9 deletions

View File

@ -127,7 +127,7 @@ def check_loop(func: Callable, strict: bool = True) -> None:
# Did not source from integration? Hard error.
if found_frame is None:
raise RuntimeError(
"Detected blocking call inside the event loop. "
f"Detected blocking call to {func.__name__} inside the event loop. "
"This is causing stability issues. Please report issue"
)
@ -142,8 +142,9 @@ def check_loop(func: Callable, strict: bool = True) -> None:
extra = ""
_LOGGER.warning(
"Detected blocking call inside the event loop. This is causing stability issues. "
"Detected blocking call to %s inside the event loop. This is causing stability issues. "
"Please report issue%s for %s doing blocking calls at %s, line %s: %s",
func.__name__,
extra,
integration,
found_frame.filename[index:],

View File

@ -105,8 +105,8 @@ async def test_check_loop_async_integration(caplog):
):
hasync.check_loop(banned_function)
assert (
"Detected blocking call inside the event loop. This is causing stability issues. "
"Please report issue for hue doing blocking calls at "
"Detected blocking call to banned_function inside the event loop. This is "
"causing stability issues. Please report issue for hue doing blocking calls at "
"homeassistant/components/hue/light.py, line 23: self.light.is_on"
in caplog.text
)
@ -136,8 +136,8 @@ async def test_check_loop_async_integration_non_strict(caplog):
):
hasync.check_loop(banned_function, strict=False)
assert (
"Detected blocking call inside the event loop. This is causing stability issues. "
"Please report issue for hue doing blocking calls at "
"Detected blocking call to banned_function inside the event loop. This is "
"causing stability issues. Please report issue for hue doing blocking calls at "
"homeassistant/components/hue/light.py, line 23: self.light.is_on"
in caplog.text
)
@ -167,9 +167,10 @@ async def test_check_loop_async_custom(caplog):
):
hasync.check_loop(banned_function)
assert (
"Detected blocking call inside the event loop. This is causing stability issues. "
"Please report issue to the custom component author for hue doing blocking calls "
"at custom_components/hue/light.py, line 23: self.light.is_on" in caplog.text
"Detected blocking call to banned_function inside the event loop. This is "
"causing stability issues. Please report issue to the custom component author "
"for hue doing blocking calls at custom_components/hue/light.py, line 23: "
"self.light.is_on" in caplog.text
)