Check if we are running in the reactorless mode, i.e. with :setting:`TWISTED_REACTOR_ENABLED` set to ``False``. As this checks the runtime state and not the setting itself, it can be wrong when executed very early, before the reactor and/or the asyncio event loop are initialized.
()
| 14 | |
| 15 | |
| 16 | def is_reactorless() -> bool: |
| 17 | """Check if we are running in the reactorless mode, i.e. with |
| 18 | :setting:`TWISTED_REACTOR_ENABLED` set to ``False``. |
| 19 | |
| 20 | As this checks the runtime state and not the setting itself, it can be |
| 21 | wrong when executed very early, before the reactor and/or the asyncio event |
| 22 | loop are initialized. |
| 23 | |
| 24 | .. note:: As this function uses |
| 25 | :func:`scrapy.utils.asyncio.is_asyncio_available()`, it has the same |
| 26 | limitations for detecting a running asyncio event loop as that one. |
| 27 | |
| 28 | .. versionadded:: 2.15.0 |
| 29 | """ |
| 30 | return is_asyncio_available() and not is_reactor_installed() |
| 31 | |
| 32 | |
| 33 | class ReactorImportHook(MetaPathFinder): |