Skip to content

Instantly share code, notes, and snippets.

@Santhin
Created January 13, 2021 19:09
Show Gist options
  • Save Santhin/69eaf42555a7559c4d1406e99410e299 to your computer and use it in GitHub Desktop.
Save Santhin/69eaf42555a7559c4d1406e99410e299 to your computer and use it in GitHub Desktop.
asyncio reactor installation
# asyncio reactor installation (CORRECT) - `reactor` must not be defined at this point
# https://docs.scrapy.org/en/latest/_modules/scrapy/utils/reactor.html?highlight=asyncio%20reactor#
import scrapy
import asyncio
from twisted.internet import asyncioreactor
scrapy.utils.reactor.install_reactor('twisted.internet.asyncioreactor.AsyncioSelectorReactor')
is_asyncio_reactor_installed = scrapy.utils.reactor.is_asyncio_reactor_installed()
print(f"Is asyncio reactor installed: {is_asyncio_reactor_installed}")
from twisted.internet import reactor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment