Skip to content

Commit 7349234

Browse files
authored
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
1 parent c691f2a commit 7349234

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

Dockerfile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,18 @@ ENV LANG C.UTF-8
66

77
# Setup base
88
RUN apk add --no-cache \
9-
python3 \
10-
git \
11-
socat
9+
python3 \
10+
git \
11+
socat \
12+
libstdc++ \
13+
&& apk add --no-cache --virtual .build-dependencies \
14+
make \
15+
python3-dev \
16+
g++ \
17+
&& pip3 install --no-cache-dir \
18+
uvloop \
19+
cchardet \
20+
&& apk del .build-dependencies
1221

1322
# Install HassIO
1423
COPY . /usr/src/hassio

hassio/__main__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,19 @@
1010
_LOGGER = logging.getLogger(__name__)
1111

1212

13+
def attempt_use_uvloop():
14+
"""Attempt to use uvloop."""
15+
try:
16+
import uvloop
17+
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
18+
except ImportError:
19+
pass
20+
21+
1322
# pylint: disable=invalid-name
1423
if __name__ == "__main__":
1524
bootstrap.initialize_logging()
25+
attempt_use_uvloop()
1626
loop = asyncio.get_event_loop()
1727

1828
if not bootstrap.check_environment():

0 commit comments

Comments
 (0)