Skip to content

Commit 7fec0ba

Browse files
authored
Merge pull request #42 from aws-solutions-library-samples/queue-agent-new-callback
[Break Glass] Add callback when a job is running
2 parents b52f729 + 39b5ef2 commit 7fec0ba

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/backend/queue_agent/src/main.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
runtime_name = os.getenv("RUNTIME_NAME", "")
3939
api_base_url = ""
4040

41+
exp_callback_when_running = os.getenv("EXP_CALLBACK_WHEN_RUNNING", "")
42+
4143
# Check current runtime type
4244
runtime_type = os.getenv("RUNTIME_TYPE", "").lower()
4345

@@ -144,6 +146,14 @@ def main():
144146
sqs_action.delete_message(message)
145147
continue
146148

149+
if (exp_callback_when_running.lower() == "true"):
150+
sns_response = {"runtime": runtime_name,
151+
'id': task_id,
152+
'status': "running",
153+
'context': context}
154+
155+
sns_action.publish_message(topic, json.dumps(sns_response))
156+
147157
# Start handling message
148158
response = {}
149159

@@ -165,9 +175,15 @@ def main():
165175

166176
output_url = s3_action.upload_file(response["content"], s3_bucket, prefix, str(task_id)+"-"+rand, ".out")
167177

178+
if response["success"]:
179+
status = "completed"
180+
else:
181+
status = "failed"
182+
168183
sns_response = {"runtime": runtime_name,
169184
'id': task_id,
170185
'result': response["success"],
186+
'status': status,
171187
'image_url': result,
172188
'output_url': output_url,
173189
'context': context}

0 commit comments

Comments
 (0)