def getenv_int(key, default=0):
    """
    Get an integer-valued environment variable `key`, if it exists and parses
    as an integer, otherwise return `default`.
    """
    try:
        return int(os.environ.get(key, str(default)))
    except ValueError:
        return default
Get an integer-valued environment variable `key`, if it exists and parses
    as an integer, otherwise return `default`.