mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 18:28:14 +02:00
Log directory blocking I/O functions that run in the event loop (#118529)
* Log directory I/O functions that run in the event loop * tests
This commit is contained in:
@ -2,8 +2,10 @@
|
||||
|
||||
import builtins
|
||||
from contextlib import suppress
|
||||
import glob
|
||||
from http.client import HTTPConnection
|
||||
import importlib
|
||||
import os
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
@ -59,8 +61,22 @@ def enable() -> None:
|
||||
loop_thread_id=loop_thread_id,
|
||||
)
|
||||
|
||||
glob.glob = protect_loop(
|
||||
glob.glob, strict_core=False, strict=False, loop_thread_id=loop_thread_id
|
||||
)
|
||||
glob.iglob = protect_loop(
|
||||
glob.iglob, strict_core=False, strict=False, loop_thread_id=loop_thread_id
|
||||
)
|
||||
|
||||
if not _IN_TESTS:
|
||||
# Prevent files being opened inside the event loop
|
||||
os.listdir = protect_loop( # type: ignore[assignment]
|
||||
os.listdir, strict_core=False, strict=False, loop_thread_id=loop_thread_id
|
||||
)
|
||||
os.scandir = protect_loop( # type: ignore[assignment]
|
||||
os.scandir, strict_core=False, strict=False, loop_thread_id=loop_thread_id
|
||||
)
|
||||
|
||||
builtins.open = protect_loop( # type: ignore[assignment]
|
||||
builtins.open,
|
||||
strict_core=False,
|
||||
|
Reference in New Issue
Block a user