File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 1
1
import json
2
2
import os
3
+ import signal
3
4
import time
4
5
import sys
5
6
import boto3
@@ -135,6 +136,26 @@ def go():
135
136
log .info ('Spinning up messages generator' )
136
137
msgs = get_msgs (sqs , Q_URL )
137
138
139
+ receipt_handle = None
140
+
141
+ # Orderly clean-up logic if process is suddenly shut down.
142
+ def clean_up (signum , frm ):
143
+ '''Attempt to cleanly reset the visiblity of the current in-flight
144
+ message before exiting. (It's possible we are exiting after
145
+ a message was deleted but the next has not yet been retrieved; that's ok'''
146
+ nonlocal sqs
147
+ nonlocal receipt_handle
148
+ log .info ('***************************' )
149
+ log .info ('SIGINT or SIGTERM received.' )
150
+ log .info ('***************************' )
151
+ try :
152
+ make_msg_visible (sqs , Q_URL , receipt_handle )
153
+ except Exception as ex :
154
+ log .error (ex )
155
+ sys .exit (0 )
156
+ signal .signal (signal .SIGINT , clean_up )
157
+ signal .signal (signal .SIGTERM , clean_up )
158
+
138
159
# Senzing init tasks.
139
160
sz_eng = None
140
161
try :
You can’t perform that action at this time.
0 commit comments