(20241010) Almost ready for deployment.
This commit is contained in:
@@ -55,8 +55,12 @@ import datetime
|
||||
|
||||
# System-level activities:
|
||||
import io
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
import os
|
||||
>>>>>>> 0450b2a445509ef536ccf8598ab31a0e4ba09f18
|
||||
|
||||
# For Pydantic data-models:
|
||||
# For Pydantic data-behaviour_models:
|
||||
import pydantic
|
||||
|
||||
# For hashing and shortening the hash:
|
||||
@@ -700,7 +704,9 @@ def should_not_be_under_maintenance(attr_name):
|
||||
|
||||
"""
|
||||
Use this decorator to reject a request when the app is being marked as "under-maintenance". You will need to create
|
||||
a boolean variable within the scope of the 'current_app' for this to work.
|
||||
a boolean variable within the scope of the 'current_app' for this to work. An alternate to this is to set the value
|
||||
in an environment variable named 'IS_UNDER_MAINTENANCE' to a string value of either 'True' or 'False' for
|
||||
multi-worker deployments.
|
||||
:param attr_name: The name of the boolean variable that will hold the information about the app being under
|
||||
maintenance. If its value is True at the time of checking, the incoming request will be rejected.
|
||||
:return: The decorator factory.
|
||||
@@ -717,7 +723,9 @@ def should_not_be_under_maintenance(attr_name):
|
||||
# Get the attribute and check if it indicates that the app is under maintenance,
|
||||
# call the wrapped function if not under maintenance:
|
||||
app_attr = getattr(current_app, attr_name)
|
||||
if app_attr: response = ResponseModel(status_code = StatusCodes.DOWN_FOR_MAINTENANCE).for_quart()
|
||||
env_attr = True if os.environ.get("IS_UNDER_MAINTENANCE", "False").lower() == "true" else False
|
||||
if app_attr or env_attr:
|
||||
response = ResponseModel(status_code = StatusCodes.DOWN_FOR_MAINTENANCE).for_quart()
|
||||
else:
|
||||
response = await func(*args, **kwargs)
|
||||
kwargs["decorator_count"] -= 1
|
||||
|
||||
Reference in New Issue
Block a user