From 734923463843e16429f76b777efee566492790d7 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Tue, 12 Dec 2017 23:38:33 +0100 Subject: [PATCH] Use uvloop & aiohttp C extension (#279) * Update Dockerfile * Update __main__.py * Update Dockerfile * Update Dockerfile * Update Dockerfile * Update Dockerfile * Update Dockerfile * Update Dockerfile * Update Dockerfile * Update Dockerfile * Update Dockerfile --- Dockerfile | 15 ++++++++++++--- hassio/__main__.py | 10 ++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index dd9592d1b..6cf63f798 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,9 +6,18 @@ ENV LANG C.UTF-8 # Setup base RUN apk add --no-cache \ - python3 \ - git \ - socat + python3 \ + git \ + socat \ + libstdc++ \ + && apk add --no-cache --virtual .build-dependencies \ + make \ + python3-dev \ + g++ \ + && pip3 install --no-cache-dir \ + uvloop \ + cchardet \ + && apk del .build-dependencies # Install HassIO COPY . /usr/src/hassio diff --git a/hassio/__main__.py b/hassio/__main__.py index 5ab7639c5..023f28470 100644 --- a/hassio/__main__.py +++ b/hassio/__main__.py @@ -10,9 +10,19 @@ import hassio.core as core _LOGGER = logging.getLogger(__name__) +def attempt_use_uvloop(): + """Attempt to use uvloop.""" + try: + import uvloop + asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) + except ImportError: + pass + + # pylint: disable=invalid-name if __name__ == "__main__": bootstrap.initialize_logging() + attempt_use_uvloop() loop = asyncio.get_event_loop() if not bootstrap.check_environment():