From 95c7236faa3e13630f1472b8a54753d814556b25 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 17 Nov 2023 22:03:07 -0600 Subject: [PATCH] Ensure I/O executor --- esphome/dashboard/web_server.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/esphome/dashboard/web_server.py b/esphome/dashboard/web_server.py index 9972808948..aa8e445816 100644 --- a/esphome/dashboard/web_server.py +++ b/esphome/dashboard/web_server.py @@ -756,9 +756,15 @@ class EditRequestHandler(BaseHandler): @authenticated @bind_config - def post(self, configuration=None): - with open(file=settings.rel_path(configuration), mode="wb") as f: + async def post(self, configuration=None): + # Atomic write + config_file = settings.rel_path(configuration) + with open(file=config_file, mode="wb") as f: f.write(self.request.body) + + await async_run_system_command( + [*DASHBOARD_COMMAND, "compile", "--only-generate", config_file] + ) self.set_status(200)