33import sys
44sys .path .insert (0 , '/opt/python/.vendor' )
55
6- from ssm_cache import SSMParameter
6+ from ssm_cache import SSMParameter , InvalidParameterError
77import time
88import random
99import json
@@ -22,12 +22,15 @@ def get_config():
2222 return - 1
2323 else :
2424 return 0
25- except Exception as e :
26- print (e )
25+ except InvalidParameterError as e :
26+ print ("{} does not exist in SSM" .format (e ))
27+ return 0
28+ except KeyError as e :
29+ print ("{} is not a valid Key in the SSM configuration" .format (e ))
2730 return 0
2831
2932
30- def delayit (method ):
33+ def delayit (func ):
3134 def latency (* args , ** kw ):
3235 delay = get_config ()
3336 start = time .time ()
@@ -40,14 +43,12 @@ def latency(*args, **kw):
4043 if random .random () > 0.5 :
4144 # random sleep time between 1 and 10 seconds
4245 time .sleep (random .randint (1 , 10 ))
43- else :
44- pass
4546
46- result = method (* args , ** kw )
47+ result = func (* args , ** kw )
4748 end = time .time ()
4849
4950 print ('Added {1:.2f}ms to {0:s}' .format (
50- method .__name__ ,
51+ func .__name__ ,
5152 (end - start ) * 1000
5253 ))
5354
0 commit comments