Skip to content

Commit

Permalink
Merge pull request #149 from gitautoai/wes
Browse files Browse the repository at this point in the history
Fix 'RuntimeWarning: coroutine 'handle_gitauto' was never awaited'
  • Loading branch information
hiroshinishio authored Jul 2, 2024
2 parents 1fecafd + 607b25c commit 9b58ba3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 23 deletions.
2 changes: 1 addition & 1 deletion cloudformation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
49 changes: 27 additions & 22 deletions scheduler.py
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down Expand Up @@ -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}

0 comments on commit 9b58ba3

Please sign in to comment.