From 2884a7f876f1bb05197787c50790290c39ab94db Mon Sep 17 00:00:00 2001 From: Ivan Shapovalov Date: Wed, 27 Jan 2021 12:50:34 +0300 Subject: [PATCH] synapse.app.base: only call gc.freeze() on CPython gc.freeze() is an implementation detail of CPython garbage collector, and notably does not exist on PyPy. Rather than playing whack-a-mole and skipping the call when under PyPy, simply restrict it to CPython because the whole gc module is implementation-defined. Signed-off-by: Ivan Shapovalov --- changelog.d/9270.misc | 2 +- synapse/app/_base.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/changelog.d/9270.misc b/changelog.d/9270.misc index 314f5d4484f6..b571cd6f1042 100644 --- a/changelog.d/9270.misc +++ b/changelog.d/9270.misc @@ -1 +1 @@ -Restore PyPy compatibility by using psycopg2cffi consistently. +Restore PyPy compatibility by using psycopg2cffi consistently and not calling CPython GC methods. diff --git a/synapse/app/_base.py b/synapse/app/_base.py index 395e202b89c7..9840a9d55b1b 100644 --- a/synapse/app/_base.py +++ b/synapse/app/_base.py @@ -16,6 +16,7 @@ import gc import logging import os +import platform import signal import socket import sys @@ -339,7 +340,7 @@ def run_sighup(*args, **kwargs): # rest of time. Doing so means less work each GC (hopefully). # # This only works on Python 3.7 - if sys.version_info >= (3, 7): + if platform.python_implementation() == "CPython" and sys.version_info >= (3, 7): gc.collect() gc.freeze()