1.. _using-asyncio: 2 3======= 4asyncio 5======= 6 7.. versionadded:: 2.0 8 9Scrapy has partial support for :mod:`asyncio`. After you :ref:`install the 10asyncio reactor <install-asyncio>`, you may use :mod:`asyncio` and 11:mod:`asyncio`-powered libraries in any :doc:`coroutine <coroutines>`. 12 13.. warning:: :mod:`asyncio` support in Scrapy is experimental, and not yet 14 recommended for production environments. Future Scrapy versions 15 may introduce related changes without a deprecation period or 16 warning. 17 18.. _install-asyncio: 19 20Installing the asyncio reactor 21============================== 22 23To enable :mod:`asyncio` support, set the :setting:`TWISTED_REACTOR` setting to 24``'twisted.internet.asyncioreactor.AsyncioSelectorReactor'``. 25 26If you are using :class:`~scrapy.crawler.CrawlerRunner`, you also need to 27install the :class:`~twisted.internet.asyncioreactor.AsyncioSelectorReactor` 28reactor manually. You can do that using 29:func:`~scrapy.utils.reactor.install_reactor`:: 30 31 install_reactor('twisted.internet.asyncioreactor.AsyncioSelectorReactor') 32 33.. _using-custom-loops: 34 35Using custom asyncio loops 36========================== 37 38You can also use custom asyncio event loops with the asyncio reactor. Set the 39:setting:`ASYNCIO_EVENT_LOOP` setting to the import path of the desired event loop class to 40use it instead of the default asyncio event loop. 41 42 43 44