From 14d2e395873ec36f195398006619089b37e7288c Mon Sep 17 00:00:00 2001 From: Hiroshi Nishio <4620828+hiroshinishio@users.noreply.github.com> Date: Tue, 2 Jul 2024 18:49:03 +0900 Subject: [PATCH 1/2] Fix 'RuntimeWarning: coroutine 'handle_gitauto' was never awaited' --- scheduler.py | 49 +++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/scheduler.py b/scheduler.py index ff870e06..fca4016b 100644 --- a/scheduler.py +++ b/scheduler.py @@ -1,5 +1,6 @@ """This is scheduled to run by AWS Lambda""" +import asyncio from config import SUPABASE_SERVICE_ROLE_KEY, SUPABASE_URL from services.gitauto_handler import handle_gitauto from services.github.github_manager import ( @@ -35,28 +36,32 @@ def schedule_handler(event, context) -> dict[str, int]: ) # Resolve that issue. - payload = { - "issue": { - "number": issue["number"], - "title": issue["title"], - "body": issue["body"], - }, - "installation": { - "id": installation_id, - }, - "repository": { - "owner": { - "type": owner_type, - "id": owner_id, - "login": owner, + payload = ( + { + "issue": { + "number": issue["number"], + "title": issue["title"], + "body": issue["body"], + }, + "installation": { + "id": installation_id, + }, + "repository": { + "owner": { + "type": owner_type, + "id": owner_id, + "login": owner, + }, + "name": repo, + "default_branch": default_branch, + }, + "sender": { + "id": user_id, + "login": user, }, - "name": repo, - "default_branch": default_branch, - }, - "sender": { - "id": user_id, - "login": user, }, - } - handle_gitauto(payload=payload, trigger_type="label") + ) + + # Use asyncio.run() to run the async function. + asyncio.run(main=handle_gitauto(payload=payload, trigger_type="label")) return {"statusCode": 200} From 607b25c688b5825c28aa70e5ac98de49b6d6e46b Mon Sep 17 00:00:00 2001 From: Hiroshi Nishio <4620828+hiroshinishio@users.noreply.github.com> Date: Tue, 2 Jul 2024 18:50:33 +0900 Subject: [PATCH 2/2] . --- cloudformation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudformation.yml b/cloudformation.yml index 0cc520c6..0ad37089 100644 --- a/cloudformation.yml +++ b/cloudformation.yml @@ -20,7 +20,7 @@ Resources: Properties: Name: SchedulerEventRule Description: "Schedule Lambda function to run every weekday at 0 AM UTC" - ScheduleExpression: cron(45 8 ? * MON-FRI *) # min hour day month day-of-week year + ScheduleExpression: cron(0 10 ? * MON-FRI *) # min hour day month day-of-week year State: ENABLED Targets: - Arn: !Ref LambdaFunctionArn