From 1b95b9745b06d5b6780d2f06f458d8813f508b26 Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 31 May 2024 15:41:16 -0700 Subject: [PATCH] fix: more blocking fixes (#899) * fix: more blocking fixes * fix function call * linting --- .../mail_and_packages/helpers.py | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/custom_components/mail_and_packages/helpers.py b/custom_components/mail_and_packages/helpers.py index ece3a762..94ba2d42 100644 --- a/custom_components/mail_and_packages/helpers.py +++ b/custom_components/mail_and_packages/helpers.py @@ -303,7 +303,9 @@ async def image_file_name( # Insert place holder image _LOGGER.debug("Copying %s to %s", mail_none, os.path.join(path, image_name)) - copyfile(mail_none, os.path.join(path, image_name)) + await hass.async_add_executor_job( + copyfile, mail_none, os.path.join(path, image_name) + ) return image_name @@ -365,17 +367,19 @@ async def fetch( nomail, ) elif sensor == AMAZON_PACKAGES: - count[sensor] = get_items( - account=account, - param=ATTR_COUNT, - fwds=amazon_fwds, - days=amazon_days, + count[sensor] = await hass.async_add_executor_job( + get_items, + account, + ATTR_COUNT, + amazon_fwds, + amazon_days, ) - count[AMAZON_ORDER] = get_items( - account=account, - param=ATTR_ORDER, - fwds=amazon_fwds, - days=amazon_days, + count[AMAZON_ORDER] = await hass.async_add_executor_job( + get_items, + account, + ATTR_ORDER, + amazon_fwds, + amazon_days, ) elif sensor == AMAZON_HUB: value = amazon_hub(account, amazon_fwds)