Fixes for Twisted Version Check and Typing Issues (#6511)

This commit is contained in:
Rohitkr117 2024-10-29 23:38:38 +05:30 committed by GitHub
parent 5bbf8124ac
commit 65ecd5d528
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 2 deletions

View File

@ -15,8 +15,10 @@ from typing import (
cast,
)
from twisted import version as twisted_version
from twisted.internet.defer import Deferred, DeferredList
from twisted.python.failure import Failure
from twisted.python.versions import Version
from scrapy.http.request import NO_CALLBACK, Request
from scrapy.settings import Settings
@ -206,8 +208,8 @@ class MediaPipeline(ABC):
# minimize cached information for failure
result.cleanFailure()
result.frames = []
result.stack = []
if twisted_version <= Version("twisted", 24, 10, 0):
result.stack = [] # type: ignore[method-assign]
# This code fixes a memory leak by avoiding to keep references to
# the Request and Response objects on the Media Pipeline cache.
#