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 11import json
22import os
3+ import signal
34import time
45import sys
56import boto3
@@ -135,6 +136,26 @@ def go():
135136 log .info ('Spinning up messages generator' )
136137 msgs = get_msgs (sqs , Q_URL )
137138
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+
138159 # Senzing init tasks.
139160 sz_eng = None
140161 try :
You can’t perform that action at this time.
0 commit comments