Thanks to visit codestin.com
Credit goes to github.com

Skip to content

is_asyncio_available() is not fully supported in extension __init__() #7812

Description

@wRAR

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions