From 45058f23f3157e9e677b9446031d97469ec71440 Mon Sep 17 00:00:00 2001 From: Patrick Uiterwijk Date: May 29 2017 10:05:09 +0000 Subject: Perform very agressive GC in the web frontend Signed-off-by: Patrick Uiterwijk Merges https://pagure.io/pagure/pull-request/2305 --- diff --git a/pagure/__init__.py b/pagure/__init__.py index d4d0fe7..124ccd0 100644 --- a/pagure/__init__.py +++ b/pagure/__init__.py @@ -17,6 +17,7 @@ __api_version__ = '0.13' import datetime # noqa: E402 +import gc # noqa: E402 import logging # noqa: E402 import logging.config # noqa: E402 import os # noqa: E402 @@ -794,6 +795,15 @@ def shutdown_session(exception=None): SESSION.remove() +# pylint: disable=unused-argument +@APP.teardown_request +def gcollect(exception=None): + """ Runs a garbage collection to get rid of any open pygit2 handles. + + Details: https://pagure.io/pagure/issue/2302""" + gc.collect() + + if perfrepo: # Do this at the very end, so that the after_request comes last. APP.after_request(perfrepo.print_stats)