Skip to content

Commit 22ef8d7

Browse files
committed
app: add configurable gc.freeze() call
* As described in https://bugs.python.org/issue31558, this improves memory usage in prefork-style runtime, like uWSGI and Celery.
1 parent d1a75bf commit 22ef8d7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

invenio_base/app.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# under the terms of the MIT License; see LICENSE file for more details.
1010

1111
"""Invenio application factory."""
12+
import gc
1213
import logging
1314
import os.path
1415
import sys
@@ -142,6 +143,9 @@ def _create_app(**kwargs):
142143
if wsgi_factory:
143144
app.wsgi_app = wsgi_factory(app, **kwargs)
144145

146+
# See https://bugs.python.org/issue31558 for how this helps with memory use
147+
if app.config.get("APP_GC_FREEZE", False):
148+
gc.freeze()
145149
return app
146150

147151
return _create_app

0 commit comments

Comments
 (0)