MCPcopy
hub / github.com/scrapy/scrapy / is_asyncio_reactor_installed

Function is_asyncio_reactor_installed

scrapy/utils/reactor.py:218–241  ·  view source on GitHub ↗

Check whether the installed reactor is :class:`~twisted.internet.asyncioreactor.AsyncioSelectorReactor`. Raise a :exc:`RuntimeError` if no reactor is installed. In a future Scrapy version, when Scrapy supports running without a Twisted reactor, this function won't be useful for checkin

()

Source from the content-addressed store, hash-verified

216
217
218def is_asyncio_reactor_installed() -> bool:
219 """Check whether the installed reactor is :class:`~twisted.internet.asyncioreactor.AsyncioSelectorReactor`.
220
221 Raise a :exc:`RuntimeError` if no reactor is installed.
222
223 In a future Scrapy version, when Scrapy supports running without a Twisted
224 reactor, this function won't be useful for checking if it's possible to use
225 asyncio features, so the code that that doesn't directly require a Twisted
226 reactor should use :func:`scrapy.utils.asyncio.is_asyncio_available`
227 instead of this function.
228
229 .. versionchanged:: 2.13
230 In earlier Scrapy versions this function silently installed the default
231 reactor if there was no reactor installed. Now it raises an exception to
232 prevent silent problems in this case.
233 """
234 if not is_reactor_installed():
235 raise RuntimeError(
236 "is_asyncio_reactor_installed() called without an installed reactor."
237 )
238
239 from twisted.internet import reactor
240
241 return isinstance(reactor, asyncioreactor.AsyncioSelectorReactor)

Callers 13

_apply_settingsMethod · 0.90
crawlMethod · 0.90
_scheduleMethod · 0.90
get_reactor_settingsFunction · 0.90
is_asyncio_availableFunction · 0.90
test_installed_reactorFunction · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90

Calls 1

is_reactor_installedFunction · 0.85

Tested by 3

get_reactor_settingsFunction · 0.72
test_installed_reactorFunction · 0.72