mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 17:27:59 +01:00
Ensure storage I/O for ignored devices runs in the executor (#7792)
This commit is contained in:
parent
1c1f3f7c55
commit
e51f3d9498
2 changed files with 4 additions and 3 deletions
|
@ -103,7 +103,7 @@ class ESPHomeDashboard:
|
||||||
self.loop = asyncio.get_running_loop()
|
self.loop = asyncio.get_running_loop()
|
||||||
self.ping_request = asyncio.Event()
|
self.ping_request = asyncio.Event()
|
||||||
self.entries = DashboardEntries(self)
|
self.entries = DashboardEntries(self)
|
||||||
self.load_ignored_devices()
|
await self.loop.run_in_executor(None, self.load_ignored_devices)
|
||||||
|
|
||||||
def load_ignored_devices(self) -> None:
|
def load_ignored_devices(self) -> None:
|
||||||
storage_path = Path(ignored_devices_storage_path())
|
storage_path = Path(ignored_devices_storage_path())
|
||||||
|
|
|
@ -544,7 +544,7 @@ class ImportRequestHandler(BaseHandler):
|
||||||
|
|
||||||
class IgnoreDeviceRequestHandler(BaseHandler):
|
class IgnoreDeviceRequestHandler(BaseHandler):
|
||||||
@authenticated
|
@authenticated
|
||||||
def post(self) -> None:
|
async def post(self) -> None:
|
||||||
dashboard = DASHBOARD
|
dashboard = DASHBOARD
|
||||||
try:
|
try:
|
||||||
args = json.loads(self.request.body.decode())
|
args = json.loads(self.request.body.decode())
|
||||||
|
@ -576,7 +576,8 @@ class IgnoreDeviceRequestHandler(BaseHandler):
|
||||||
else:
|
else:
|
||||||
dashboard.ignored_devices.discard(ignored_device.device_name)
|
dashboard.ignored_devices.discard(ignored_device.device_name)
|
||||||
|
|
||||||
dashboard.save_ignored_devices()
|
loop = asyncio.get_running_loop()
|
||||||
|
await loop.run_in_executor(None, dashboard.save_ignored_devices)
|
||||||
|
|
||||||
self.set_status(204)
|
self.set_status(204)
|
||||||
self.finish()
|
self.finish()
|
||||||
|
|
Loading…
Reference in a new issue