mirror of
https://github.com/apache/superset.git
synced 2026-04-20 00:24:38 +00:00
feat: add optional garbage collection after requests (#35061)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
committed by
GitHub
parent
966e231f94
commit
d0cc6f115b
@@ -626,6 +626,8 @@ DEFAULT_FEATURE_FLAGS: dict[str, bool] = {
|
|||||||
"DATE_RANGE_TIMESHIFTS_ENABLED": False,
|
"DATE_RANGE_TIMESHIFTS_ENABLED": False,
|
||||||
# Enable Matrixify feature for matrix-style chart layouts
|
# Enable Matrixify feature for matrix-style chart layouts
|
||||||
"MATRIXIFY": False,
|
"MATRIXIFY": False,
|
||||||
|
# Force garbage collection after every request
|
||||||
|
"FORCE_GARBAGE_COLLECTION_AFTER_EVERY_REQUEST": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
# ------------------------------
|
# ------------------------------
|
||||||
|
|||||||
@@ -638,6 +638,17 @@ class SupersetAppInitializer: # pylint: disable=too-many-public-methods
|
|||||||
response.headers[k] = v
|
response.headers[k] = v
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
@self.superset_app.after_request
|
||||||
|
def cleanup_analytics_memory(response: Response) -> Response:
|
||||||
|
"""Force garbage collection after each request if feature flag enabled"""
|
||||||
|
if feature_flag_manager.is_feature_enabled(
|
||||||
|
"FORCE_GARBAGE_COLLECTION_AFTER_EVERY_REQUEST"
|
||||||
|
):
|
||||||
|
import gc
|
||||||
|
|
||||||
|
gc.collect()
|
||||||
|
return response
|
||||||
|
|
||||||
@self.superset_app.context_processor
|
@self.superset_app.context_processor
|
||||||
def get_common_bootstrap_data() -> dict[str, Any]:
|
def get_common_bootstrap_data() -> dict[str, Any]:
|
||||||
# Import here to avoid circular imports
|
# Import here to avoid circular imports
|
||||||
|
|||||||
Reference in New Issue
Block a user