Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defer importing twisted.internet.reactor, fixes "reactor already installed" #93

Merged

Conversation

minijackson
Copy link
Contributor

While running RecCeiver with 24.3.0, I found the same issue as #37:

The specified reactor cannot be used, failed with error: reactor already installed.

but initializing a dropin.cache did not work out for me. After some research, I found scrapy's asyncio documentation:

https://docs.scrapy.org/en/latest/topics/asyncio.html#handling-a-pre-installed-reactor

Turns out importing twisted.internet.reactor initializes a default reactor, which makes it impossible to change the reactor in the command-line (-r option).

So this PR defers importing reactor, which makes RecCeiver work for me.

This PR was only crudely tested, by seeing that the application doesn't crash.

importing that module initializes the reactor,
which makes it impossible to change the reactor in the command-line
(-r option). Using the command-line option failed with the message:

    The specified reactor cannot be used, failed with error: reactor already installed.

Found in scrapy's asyncio documentation:

https://docs.scrapy.org/en/latest/topics/asyncio.html#handling-a-pre-installed-reactor
Copy link

sonarqubecloud bot commented Aug 7, 2024

@tynanford tynanford requested review from jacomago and shroffk August 7, 2024 23:57
@tynanford
Copy link
Contributor

Nice! This PR works for me and avoids the old hacks we had to avoid the "reactor already installed" issue. Tested with twisted 16.4.0 and 22.4.0 and confirmed CF is populated as normal

@shroffk shroffk requested a review from tynanford August 8, 2024 14:47
@shroffk shroffk merged commit d3ae599 into ChannelFinder:master Aug 8, 2024
7 checks passed
@minijackson minijackson deleted the fix-reactor-already-installed branch August 21, 2024 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants