Patch http.client to not do I/O in the event loop (#34194)
This commit is contained in:
parent
5bfc1f3d4d
commit
d011b46985
4 changed files with 163 additions and 3 deletions
14
homeassistant/block_async_io.py
Normal file
14
homeassistant/block_async_io.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
"""Block I/O being done in asyncio."""
|
||||
from http.client import HTTPConnection
|
||||
|
||||
from homeassistant.util.async_ import protect_loop
|
||||
|
||||
|
||||
def enable() -> None:
|
||||
"""Enable the detection of I/O in the event loop."""
|
||||
# Prevent urllib3 and requests doing I/O in event loop
|
||||
HTTPConnection.putrequest = protect_loop(HTTPConnection.putrequest)
|
||||
|
||||
# Currently disabled. pytz doing I/O when getting timezone.
|
||||
# Prevent files being opened inside the event loop
|
||||
# builtins.open = protect_loop(builtins.open)
|
Loading…
Add table
Add a link
Reference in a new issue