Skip to content

Commit

Permalink
✨ Fix signal alarm issue
Browse files Browse the repository at this point in the history
  • Loading branch information
kmoberg committed Jan 15, 2024
1 parent 0d1e154 commit 35a1e84
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import cProfile
import json
import os
import signal
import time
import urllib.parse

Expand Down Expand Up @@ -69,9 +68,6 @@ def timeout_handler(signum, frame):
raise TimeoutException("Timeout handler triggered!")


# signal.signal(signal.SIGALRM, timeout_handler)


zny_web_instance = "https://nyartcc.org"


Expand Down Expand Up @@ -186,8 +182,6 @@ def updateUsers(ts3conn, conn):
:return:
"""

conn = conn

def sendMessageReg(client_unique_identifier, clid):
"""
Send a message to a user to register on the ZNY website.
Expand Down Expand Up @@ -357,19 +351,27 @@ def lambda_handler(event, context):

# Get the IP address of the ZNY-Website-Production EC2 instance
# zny_web_instance_ip = ZNY_WEB_SERVER_IP
signal.alarm(15)

with ts3.query.TS3Connection(tsHostname, "10011") as ts3conn:
ts3conn.login(client_login_name=tsUsername, client_login_password=tsPass)
ts3conn.use(sid=1)
conn = engine.connect()
updatePos(ts3conn, conn)
updateUsers(ts3conn, conn)

return {
"statusCode": 200,
"headers": {},
"body": json.dumps({
"message": f"Ran successfully! {updateCount} updates were made. {failCount} failed.",
}),
}

try:
with ts3.query.TS3Connection(tsHostname, "10011") as ts3conn:
ts3conn.login(client_login_name=tsUsername, client_login_password=tsPass)
ts3conn.use(sid=1)
conn = engine.connect()
updatePos(ts3conn, conn)
updateUsers(ts3conn, conn)

return {
"statusCode": 200,
"headers": {},
"body": json.dumps({
"message": f"Ran successfully! {updateCount} updates were made. {failCount} failed.",
}),
}
except Error as e:
return {
"statusCode": 500,
"headers": {},
"body": json.dumps({
"message": f"Timed out after 15 seconds."
}),
}

0 comments on commit 35a1e84

Please sign in to comment.