Last active
April 9, 2022 18:27
-
-
Save yogeshnile/830d5685bb2ebb79a91611db6b407ded to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import signal | |
import boto3 | |
import os | |
def lambda_handler(event, context): | |
signal.alarm(int(context.get_remaining_time_in_millis() / 1000) - 1) | |
signal.signal(signal.SIGALRM, timeout_handler) | |
# Do other stuff | |
while True: | |
pass | |
def timeout_handler(_signal, _frame): | |
client = boto3.client('sns') | |
LAMBDA_NAME = os.environ['AWS_LAMBDA_FUNCTION_NAME'] | |
response = client.publish( | |
TopicArn = 'string', | |
Subject = f'{LAMBDA_NAME} getting timeout.', | |
Message = f'{LAMBDA_NAME} lambda getting timeout please review it.' | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment