Scrapy, a fast high-level web crawling & scraping framework for Python.
Install the asyncio reactor on "import scrapy".
Andrey Rakhmatullin1b437bbe9fa0
diff --git a/scrapy/__init__.py b/scrapy/__init__.pyindex 230e5cee3..41eaee959 100644--- a/scrapy/__init__.py+++ b/scrapy/__init__.py@@ -23,6 +23,28 @@ import warningswarnings.filterwarnings('ignore', category=DeprecationWarning, module='twisted')del warnings+# Install twisted asyncio loop+def _install_asyncio_reactor():+ global asyncio_supported+ try:+ import asyncio+ from twisted.internet import asyncioreactor+ except ImportError:+ pass+ else:+ from twisted.internet.error import ReactorAlreadyInstalledError+ try:+ asyncioreactor.install(asyncio.get_event_loop())+ asyncio_supported = True+ except ReactorAlreadyInstalledError:+ import twisted.internet.reactor+ if isinstance(twisted.internet.reactor,+ asyncioreactor.AsyncioSelectorReactor):+ asyncio_supported = True+asyncio_supported = False+_install_asyncio_reactor()+del _install_asyncio_reactor+# Apply monkey patches to fix issues in external librariesfrom . import _monkeypatchesdel _monkeypatches