Check that `gc` method is available before using in `synapse/app/_base` (#11816)

* add check that gc.freeze is available before calling

* newsfragment

* lint

* Update comment

Co-authored-by: Dan Callahan <danc@element.io>

Co-authored-by: Dan Callahan <danc@element.io>
matthew/custom-edus
Shay 2022-01-25 10:35:18 -08:00 committed by GitHub
parent 6a72c910f1
commit b8bf600700
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

1
changelog.d/11816.misc Normal file
View File

@ -0,0 +1 @@
Drop support for Python 3.6, which is EOL.

View File

@ -468,12 +468,14 @@ async def start(hs: "HomeServer") -> None:
# everything currently allocated are things that will be used for the
# rest of time. Doing so means less work each GC (hopefully).
#
gc.collect()
gc.freeze()
# PyPy does not (yet?) implement gc.freeze()
if hasattr(gc, "freeze"):
gc.collect()
gc.freeze()
# Speed up shutdowns by freezing all allocated objects. This moves everything
# into the permanent generation and excludes them from the final GC.
atexit.register(gc.freeze)
# Speed up shutdowns by freezing all allocated objects. This moves everything
# into the permanent generation and excludes them from the final GC.
atexit.register(gc.freeze)
def setup_sentry(hs: "HomeServer") -> None: