Force garbage collection for PyPy support

This commit is contained in:
Adrián Chaves 2024-07-09 13:01:52 +02:00
parent 11213cc44e
commit ec7dbfd6a5
1 changed files with 4 additions and 0 deletions

View File

@ -1,5 +1,6 @@
from __future__ import annotations
import gc
import random
import warnings
from collections import deque
@ -205,6 +206,9 @@ class Downloader:
f"request_backouts/response_max_active_size stat."
)
self._count_backout("response_max_active_size")
# Force the garbage collection of response objects. Necessary for
# PyPy, which is lazier when it comes to garbage collection.
gc.collect()
return True
return False