While a lambda is still processing (archive unpacking etc), the lambda state should be set to "Pending" (currently "Active") and invocations to that lambda should fail (currently, it can end up in a inconsistent state in this case, like lambdas being executed without layers).

Lambda state should reflect the current internal state, and invocations should fail if not active.
from localstack.utils.docker_utils import DOCKER_CLIENT
from localstack.utils.functions import run_safe
from localstack.utils.http import canonicalize_headers, parse_chunked_data
from localstack.utils.patch import patch
LOG = logging.getLogger(__name__)
LAMBDA_POLICY_NAME_PATTERN = "lambda_policy_{name}_{qualifier}"
LAMBDA_TEST_ROLE = "arn:aws:iam::{account_id}:role/lambda-test-role"
APP_NAME = "lambda_api"
ARCHIVE_FILE_PATTERN = "%s/lambda.handler.*.jar" % config.dirs.tmp
LAMBDA_SCRIPT_PATTERN = "%s/lambda_script_*.py" % config.dirs.tmp
LAMBDA_ZIP_FILE_NAME = "original_lambda_archive.zip"
LAMBDA_JAR_FILE_NAME = "original_lambda_archive.jar"
LAMBDA_DEFAULT_TIMEOUT = 3
INVALID_PARAMETER_VALUE_EXCEPTION = "InvalidParameterValueException"
VERSION_LATEST = LambdaFunction.QUALIFIER_LATEST
FUNCTION_MAX_SIZE = 69905067
FUNCTION_MAX_UNZIPPED_SIZE = 262144000
BATCH_SIZE_RANGES = {
    "kafka": (100, 10000),
    "kinesis": (100, 10000),
    "dynamodb": (100, 1000),
    "sqs": (
        10,
        10,
    ),  
}
DATE_FORMAT = "%Y-%m-%dT%H:%M:%S.%f+00:00"
app = Flask(APP_NAME)
@patch(app.route)
def app_route(self, fn, *args, **kwargs):