2020-04-15 22:32:10 +00:00
|
|
|
"""Block I/O being done in asyncio."""
|
|
|
|
from http.client import HTTPConnection
|
|
|
|
|
2021-12-23 19:14:47 +00:00
|
|
|
from .util.async_ import protect_loop
|
2020-04-15 22:32:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
def enable() -> None:
|
|
|
|
"""Enable the detection of I/O in the event loop."""
|
|
|
|
# Prevent urllib3 and requests doing I/O in event loop
|
2020-07-22 15:06:37 +00:00
|
|
|
HTTPConnection.putrequest = protect_loop(HTTPConnection.putrequest) # type: ignore
|
2020-04-15 22:32:10 +00:00
|
|
|
|
|
|
|
# Currently disabled. pytz doing I/O when getting timezone.
|
|
|
|
# Prevent files being opened inside the event loop
|
|
|
|
# builtins.open = protect_loop(builtins.open)
|