mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Remove uvloop event policy (#29835)
* Remove uvloop event policy * Clean tests * Fix lint * Cleanup statment
This commit is contained in:
parent
01ef44fd68
commit
0c796fc3c3
@ -15,12 +15,10 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
|
|
||||||
def set_loop() -> None:
|
def set_loop() -> None:
|
||||||
"""Attempt to use uvloop."""
|
"""Attempt to use different loop."""
|
||||||
import asyncio
|
import asyncio
|
||||||
from asyncio.events import BaseDefaultEventLoopPolicy
|
from asyncio.events import BaseDefaultEventLoopPolicy
|
||||||
|
|
||||||
policy = None
|
|
||||||
|
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
if hasattr(asyncio, "WindowsProactorEventLoopPolicy"):
|
if hasattr(asyncio, "WindowsProactorEventLoopPolicy"):
|
||||||
# pylint: disable=no-member
|
# pylint: disable=no-member
|
||||||
@ -33,15 +31,7 @@ def set_loop() -> None:
|
|||||||
_loop_factory = asyncio.ProactorEventLoop
|
_loop_factory = asyncio.ProactorEventLoop
|
||||||
|
|
||||||
policy = ProactorPolicy()
|
policy = ProactorPolicy()
|
||||||
else:
|
|
||||||
try:
|
|
||||||
import uvloop
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
policy = uvloop.EventLoopPolicy()
|
|
||||||
|
|
||||||
if policy is not None:
|
|
||||||
asyncio.set_event_loop_policy(policy)
|
asyncio.set_event_loop_policy(policy)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
"""Set up some common test helper things."""
|
"""Set up some common test helper things."""
|
||||||
import asyncio
|
|
||||||
import functools
|
import functools
|
||||||
import logging
|
import logging
|
||||||
import os
|
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@ -25,10 +23,6 @@ from tests.common import ( # noqa: E402, isort:skip
|
|||||||
)
|
)
|
||||||
from tests.test_util.aiohttp import mock_aiohttp_client # noqa: E402, isort:skip
|
from tests.test_util.aiohttp import mock_aiohttp_client # noqa: E402, isort:skip
|
||||||
|
|
||||||
if os.environ.get("UVLOOP") == "1":
|
|
||||||
import uvloop
|
|
||||||
|
|
||||||
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
logging.getLogger("sqlalchemy.engine").setLevel(logging.INFO)
|
logging.getLogger("sqlalchemy.engine").setLevel(logging.INFO)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user