libs/firebase_config.py
def update_firebase_instance(rucur_depth=3) -> None:
    """ Creates or destroys the firebase app, handling basic credential errors. """
    junk_creds = False
    encoded_credentials = None  # IDE complains

    try:
        encoded_credentials = json.loads(safely_get_db_credential(BACKEND_FIREBASE_CREDENTIALS))
    except (JSONDecodeError, TypeError):
        junk_creds = True

    try:
        delete_firebase_instance(get_firebase_app())
    except ValueError:
        # occurs when get_firebase_app() fails, delete_firebase_instance is only called if it succeeds.
        pass

    if junk_creds:
        return

    # can now ~safely initialize the firebase app, re-casting any errors for runime scenarios
    # errors at this point should only occur if the app has somehow gotten broken credentials.
    try:
        cert = FirebaseCertificate(encoded_credentials)
    except ValueError as e:
        raise FirebaseMisconfigured(str(e))

    try:
        initialize_firebase_app(cert)
    except ValueError as e:
        # occasionally we do hit a race condition, handle that with 3 tries, comment in error message.
        if rucur_depth >= 0:
            return update_firebase_instance(rucur_depth - 1)
        raise FirebaseMisconfigured(
            "This error is usually caused by a race condition, please report it if this happens frequently: "
            + str(e)
        )
 Creates or destroys the firebase app, handling basic credential errors. 
Creates or destroys the firebase app, handling basic credential errors.
Creates or destroys the firebase app handling basic credential errors .
def update_firebase_instance(rucur_depth=3) -> None:
    junk_creds = False
    encoded_credentials = None  
    try:
        encoded_credentials = json.loads(safely_get_db_credential(BACKEND_FIREBASE_CREDENTIALS))
    except (JSONDecodeError, TypeError):
        junk_creds = True
    try:
        delete_firebase_instance(get_firebase_app())
    except ValueError:
        pass
    if junk_creds:
        return
    try:
        cert = FirebaseCertificate(encoded_credentials)
    except ValueError as e:
        raise FirebaseMisconfigured(str(e))
    try:
        initialize_firebase_app(cert)
    except ValueError as e:
        if rucur_depth >= 0:
            return update_firebase_instance(rucur_depth - 1)
        raise FirebaseMisconfigured(
            "This error is usually caused by a race condition, please report it if this happens frequently: "
            + str(e)
        )
def update_firebase_instance ( rucur_depth = 3 ) -> None : junk_creds = False encoded_credentials = None try : encoded_credentials = json . loads ( safely_get_db_credential ( BACKEND_FIREBASE_CREDENTIALS ) ) except ( JSONDecodeError , TypeError ) : junk_creds = True try : delete_firebase_instance ( get_firebase_app ( ) ) except ValueError : pass if junk_creds : return try : cert = FirebaseCertificate ( encoded_credentials ) except ValueError as e : raise FirebaseMisconfigured ( str ( e ) ) try : initialize_firebase_app ( cert ) except ValueError as e : if rucur_depth >= 0 : return update_firebase_instance ( rucur_depth - 1 ) raise FirebaseMisconfigured ( "This error is usually caused by a race condition, please report it if this happens frequently: " + str ( e ) )
Creates or destroys the firebase app, handling basic credential errors.
Creates or destroys the firebase app handling basic credential errors .
""" Creates or destroys the firebase app, handling basic credential errors. """ # IDE complains # occurs when get_firebase_app() fails, delete_firebase_instance is only called if it succeeds. # can now ~safely initialize the firebase app, re-casting any errors for runime scenarios # errors at this point should only occur if the app has somehow gotten broken credentials. # occasionally we do hit a race condition, handle that with 3 tries, comment in error message.
rucur_depth