mirror of https://github.com/scrapy/scrapy.git
More docs for the is_asyncio_reactor_installed() behavior change. (#6866)
This commit is contained in:
parent
d99234a33f
commit
405d9bc8a2
|
|
@ -126,6 +126,15 @@ Backward-incompatible changes
|
|||
also enforced for start requests.
|
||||
(:issue:`6777`)
|
||||
|
||||
- Calling :func:`scrapy.utils.reactor.is_asyncio_reactor_installed` without
|
||||
an installed reactor now raises an exception instead of installing a
|
||||
reactor. This shouldn't affect normal Scrapy use cases, but it may affect
|
||||
3rd-party test suites that use Scrapy internals such as
|
||||
:class:`~scrapy.crawler.Crawler` and don't install a reactor explicitly. If
|
||||
you are affected by this change, you most likely need to install the
|
||||
reactor before running Scrapy code that expects it to be installed.
|
||||
(:issue:`6732`, :issue:`6735`)
|
||||
|
||||
- The ``from_settings()`` method of
|
||||
:class:`~scrapy.spidermiddlewares.urllength.UrlLengthMiddleware`,
|
||||
deprecated in Scrapy 2.12.0, is removed earlier than the usual deprecation
|
||||
|
|
|
|||
|
|
@ -202,6 +202,11 @@ def is_asyncio_reactor_installed() -> bool:
|
|||
"""Check whether the installed reactor is :class:`~twisted.internet.asyncioreactor.AsyncioSelectorReactor`.
|
||||
|
||||
Raise a :exc:`RuntimeError` if no reactor is installed.
|
||||
|
||||
.. versionchanged:: 2.13
|
||||
In earlier Scrapy versions this function silently installed the default
|
||||
reactor if there was no reactor installed. Now it raises an exception to
|
||||
prevent silent problems in this case.
|
||||
"""
|
||||
if not is_reactor_installed():
|
||||
raise RuntimeError(
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ from twisted.trial.unittest import SkipTest
|
|||
from scrapy.exceptions import ScrapyDeprecationWarning
|
||||
from scrapy.utils.boto import is_botocore_available
|
||||
from scrapy.utils.deprecate import create_deprecated_class
|
||||
from scrapy.utils.reactor import is_asyncio_reactor_installed
|
||||
from scrapy.utils.reactor import is_asyncio_reactor_installed, is_reactor_installed
|
||||
from scrapy.utils.spider import DefaultSpider
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
|
@ -117,6 +117,11 @@ def get_reactor_settings() -> dict[str, Any]:
|
|||
settings, so tests that run the crawler in the current process may need to
|
||||
pass a correct ``"TWISTED_REACTOR"`` setting value when creating it.
|
||||
"""
|
||||
if not is_reactor_installed():
|
||||
raise RuntimeError(
|
||||
"get_reactor_settings() called without an installed reactor,"
|
||||
" you may need to install a reactor explicitly when running your tests."
|
||||
)
|
||||
settings: dict[str, Any] = {}
|
||||
if not is_asyncio_reactor_installed():
|
||||
settings["TWISTED_REACTOR"] = None
|
||||
|
|
|
|||
Loading…
Reference in New Issue