def get_state(key, namespace=None, table_name=None, environment=None,<EOL>layer=None, stage=None, shard_id=None, consistent=True,<EOL>deserializer=json.loads, wait_exponential_multiplier=<NUM_LIT>,<EOL>wait_exponential_max=<NUM_LIT>, stop_max_delay=<NUM_LIT>):
if table_name is None:<EOL><INDENT>table_name = _state_table_name(environment=environment, layer=layer,<EOL>stage=stage)<EOL><DEDENT>if not table_name:<EOL><INDENT>msg = ("<STR_LIT>"<EOL>"<STR_LIT>".format(key))<EOL>logger.error(msg)<EOL>raise StateTableError(msg)<EOL>return<EOL><DEDENT>dynamodb = boto3.resource("<STR_LIT>")<EOL>table = dynamodb.Table(table_name)<EOL>logger.info("<STR_LIT>".format(key, table_name))<EOL>if namespace:<EOL><INDENT>key = "<STR_LIT>".format(namespace, key)<EOL><DEDENT>if shard_id:<EOL><INDENT>key = "<STR_LIT>".format(shard_id, key)<EOL><DEDENT>@retry(retry_on_exception=_is_critical_exception,<EOL>wait_exponential_multiplier=wait_exponential_multiplier,<EOL>wait_exponential_max=wait_exponential_max,<EOL>stop_max_delay=stop_max_delay)<EOL>def get_item():<EOL><INDENT>try:<EOL><INDENT>return table.get_item(<EOL>Key={"<STR_LIT:id>": key}, ConsistentRead=consistent).get(<EOL>"<STR_LIT>", {}).get("<STR_LIT:value>")<EOL><DEDENT>except Exception as err:<EOL><INDENT>if _is_dynamodb_critical_exception(err):<EOL><INDENT>raise CriticalError(err)<EOL><DEDENT>else:<EOL><INDENT>raise<EOL><DEDENT><DEDENT><DEDENT>value = get_item()<EOL>if not value:<EOL><INDENT>return<EOL><DEDENT>if deserializer:<EOL><INDENT>try:<EOL><INDENT>value = deserializer(value)<EOL><DEDENT>except ValueError:<EOL><INDENT>logger.error("<STR_LIT>".format(value))<EOL>return value<EOL><DEDENT><DEDENT>return value<EOL>
Get Lambda state value(s).