Skip to content

Commit

Permalink
fix: async for blocking file system operations
Browse files Browse the repository at this point in the history
  • Loading branch information
geertmeersman committed Oct 8, 2024
1 parent 7ee7acf commit cf27ddd
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions custom_components/robonect/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""The Robonect component."""

import asyncio
from datetime import timedelta
import logging
from pathlib import Path
Expand Down Expand Up @@ -219,7 +218,7 @@ def remove_storage_files():
storage_dir.rmdir()

# Offload the file system operations to a thread
await asyncio.to_thread(remove_storage_files)
await hass.async_add_executor_job(remove_storage_files)


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
Expand All @@ -240,7 +239,7 @@ def remove_storage_files():
storage_dir.rmdir()

# Offload the file system operations to a thread
await asyncio.to_thread(remove_storage_files)
await hass.async_add_executor_job(remove_storage_files)

return unload_ok

Expand Down

0 comments on commit cf27ddd

Please sign in to comment.