Scrapy, a fast high-level web crawling & scraping framework for Python.
Deprecate scrapy.utils.defer.process_chain_both(). (#6397)
Andrey Rakhmatullinddc98fe91b45
diff --git a/scrapy/utils/defer.py b/scrapy/utils/defer.pyindex abb7e1726..f60b7dde8 100644--- a/scrapy/utils/defer.py+++ b/scrapy/utils/defer.py@@ -6,6 +6,7 @@ from __future__ import annotationsimport asyncioimport inspect+import warningsfrom asyncio import Futurefrom functools import wrapsfrom types import CoroutineType@@ -35,7 +36,7 @@ from twisted.internet.task import Cooperatorfrom twisted.python import failurefrom twisted.python.failure import Failure-from scrapy.exceptions import IgnoreRequest+from scrapy.exceptions import IgnoreRequest, ScrapyDeprecationWarningfrom scrapy.utils.reactor import _get_asyncio_event_loop, is_asyncio_reactor_installedif TYPE_CHECKING:@@ -281,6 +282,12 @@ def process_chain_both(**kw: _P.kwargs,) -> Deferred:"""Return a Deferred built by chaining the given callbacks and errbacks"""+ warnings.warn(+ "process_chain_both() is deprecated and will be removed in a future"+ " Scrapy version.",+ ScrapyDeprecationWarning,+ stacklevel=2,+ )d: Deferred = Deferred()for cb, eb in zip(callbacks, errbacks):d.addCallback(cb, *a, **kw)diff --git a/tests/test_utils_defer.py b/tests/test_utils_defer.pyindex a7d54b565..ec0399865 100644--- a/tests/test_utils_defer.py+++ b/tests/test_utils_defer.py@@ -14,7 +14,6 @@ from scrapy.utils.defer import (mustbe_deferred,parallel_async,process_chain,- process_chain_both,process_parallel,)@@ -80,19 +79,6 @@ class DeferUtilsTest(unittest.TestCase):gotexc = Trueself.assertTrue(gotexc)- @defer.inlineCallbacks- def test_process_chain_both(self):- x = yield process_chain_both(- [cb_fail, cb2, cb3], [None, eb1, None], "res", "v1", "v2"- )- self.assertEqual(x, "(cb3 (eb1 TypeError v1 v2) v1 v2)")-- fail = Failure(ZeroDivisionError())- x = yield process_chain_both(- [eb1, cb2, cb3], [eb1, None, None], fail, "v1", "v2"- )- self.assertEqual(x, "(cb3 (cb2 (eb1 ZeroDivisionError v1 v2) v1 v2) v1 v2)")-@defer.inlineCallbacksdef test_process_parallel(self):x = yield process_parallel([cb1, cb2, cb3], "res", "v1", "v2")