Despite what the docs say you cannot call it in an extension __init__() to check whether asyncio support is available, as the extensions are created too early, in Crawler._apply_settings(), before the loop runs.
I initially thought that this won't work when designing this way to check for asyncio support, but then decided that it will work, and I apparently was wrong.
The same should apply to is_reactorless() as it calls is_asyncio_available() (but we already check the TWISTED_REACTOR_ENABLED setting in our components instead, IIRC because I felt that it may be more robust).
It should be possible to only change the recommendation for the initialization code instead of changing the behavior of functions. We may even try my old rejected idea of adding a flag to Crawler, so that the initialization code can use that while generic code that doesn't have the crawler but runs later than the initialization can use the functions.
Despite what the docs say you cannot call it in an extension
__init__()to check whether asyncio support is available, as the extensions are created too early, inCrawler._apply_settings(), before the loop runs.I initially thought that this won't work when designing this way to check for asyncio support, but then decided that it will work, and I apparently was wrong.
The same should apply to
is_reactorless()as it callsis_asyncio_available()(but we already check theTWISTED_REACTOR_ENABLEDsetting in our components instead, IIRC because I felt that it may be more robust).It should be possible to only change the recommendation for the initialization code instead of changing the behavior of functions. We may even try my old rejected idea of adding a flag to
Crawler, so that the initialization code can use that while generic code that doesn't have the crawler but runs later than the initialization can use the functions.