662. Processes async operations when invoked by itself to avoid timeouts
77"""
88
9- import asyncio
109from slack_bolt .adapter .aws_lambda import SlackRequestHandler
1110from aws_lambda_powertools .utilities .typing import LambdaContext
1211
@@ -42,10 +41,9 @@ def handler(event: dict, context: LambdaContext) -> dict:
4241 When subsequent actions or events are processed, this is looked up, and if it exists, then the pull request lambda
4342 is triggered with either pull_request_event or pull_request_action
4443 """
45- loop = asyncio .get_event_loop ()
4644 # direct invocation bypasses slack infrastructure entirely
4745 if event .get ("invocation_type" ) == "direct" :
48- return loop . run_until_complete ( handle_direct_invocation (event , context ) )
46+ return handle_direct_invocation (event , context )
4947
5048 app = get_app (logger = logger )
5149 # handle pull request processing requests
@@ -68,10 +66,10 @@ def handler(event: dict, context: LambdaContext) -> dict:
6866
6967 # handle Slack webhook requests
7068 slack_handler = SlackRequestHandler (app = app )
71- return loop . run_until_complete ( slack_handler .handle (event = event , context = context ) )
69+ return slack_handler .handle (event = event , context = context )
7270
7371
74- async def handle_direct_invocation (event : dict [str , Any ], context : LambdaContext ) -> DirectInvocationResponse :
72+ def handle_direct_invocation (event : dict [str , Any ], context : LambdaContext ) -> DirectInvocationResponse :
7573 """direct lambda invocation for ai assistance - bypasses slack entirely"""
7674 try :
7775 # validate request structure using type guard
@@ -84,7 +82,7 @@ async def handle_direct_invocation(event: dict[str, Any], context: LambdaContext
8482 # shared logic: same AI processing as slack handlers use
8583 from app .services .ai_processor import process_ai_query
8684
87- ai_response = await process_ai_query (query , session_id )
85+ ai_response = process_ai_query (query , session_id )
8886
8987 return create_success_response (
9088 text = ai_response ["text" ],
0 commit comments