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

ReactorAlreadyInstalledError #79

Closed
glyph opened this issue Oct 22, 2016 · 8 comments · Fixed by #82
Closed

ReactorAlreadyInstalledError #79

glyph opened this issue Oct 22, 2016 · 8 comments · Fixed by #82
Labels
Milestone

Comments

@glyph
Copy link
Member

glyph commented Oct 22, 2016

$ mktmpenv
...
$ pip install txacme
...
Successfully installed Twisted-16.4.1 acme-0.9.3 attrs-16.2.0 cffi-1.8.3 cryptography-1.5.2 eliot-0.11.0 enum34-1.1.6 funcsigs-1.0.2 idna-2.1 ipaddress-1.0.17 mock-2.0.0 ndg-httpsclient-0.4.2 pbr-1.10.0 pem-16.1.0 pyOpenSSL-16.2.0 pyasn1-0.1.9 pyasn1-modules-0.0.8 pycparser-2.16 pyrfc3339-1.0 pyrsistent-0.11.13 pytz-2016.7 requests-2.11.1 service-identity-16.0.0 six-1.10.0 treq-15.1.0 txacme-0.9.0 txsni-0.1.6 zope.interface-4.3.2
$ twist --help
Traceback (most recent call last):
  File "/Users/glyph/.virtualenvs/tmp-4d999315aefd700e/bin/twist", line 11, in <module>
    sys.exit(Twist.main())
  File "/Users/glyph/.virtualenvs/tmp-4d999315aefd700e/lib/python2.7/site-packages/twisted/application/twist/_twist.py", line 132, in main
    options = cls.options(argv)
  File "/Users/glyph/.virtualenvs/tmp-4d999315aefd700e/lib/python2.7/site-packages/twisted/application/twist/_twist.py", line 38, in options
    options.parseOptions(argv[1:])
  File "/Users/glyph/.virtualenvs/tmp-4d999315aefd700e/lib/python2.7/site-packages/twisted/application/twist/_options.py", line 157, in parseOptions
    self.installReactor()
  File "/Users/glyph/.virtualenvs/tmp-4d999315aefd700e/lib/python2.7/site-packages/twisted/application/twist/_options.py", line 77, in installReactor
    self["reactor"] = installReactor(name)
  File "/Users/glyph/.virtualenvs/tmp-4d999315aefd700e/lib/python2.7/site-packages/twisted/application/reactors.py", line 82, in installReactor
    installer.install()
  File "/Users/glyph/.virtualenvs/tmp-4d999315aefd700e/lib/python2.7/site-packages/twisted/application/reactors.py", line 60, in install
    namedAny(self.moduleName).install()
  File "/Users/glyph/.virtualenvs/tmp-4d999315aefd700e/lib/python2.7/site-packages/twisted/internet/selectreactor.py", line 198, in install
    installReactor(reactor)
  File "/Users/glyph/.virtualenvs/tmp-4d999315aefd700e/lib/python2.7/site-packages/twisted/internet/main.py", line 32, in installReactor
    raise error.ReactorAlreadyInstalledError("reactor already installed")
twisted.internet.error.ReactorAlreadyInstalledError: reactor already installed

This doesn't happen with twisted[tls], so I'm assuming it's txacme's fault, but I haven't investigated much further than this.

@mithrandi
Copy link
Contributor

This seems to be fixed in master already (I can reproduce with txacme 0.9.0, but not with master), but I don't actually know what's going on here, so it may still warrant further investigation.

@mithrandi mithrandi added the bug label Oct 22, 2016
@glyph
Copy link
Member Author

glyph commented Oct 22, 2016

I can reproduce with master. Try mktmpenv; pip install git+https://github.com/mithrandi/txacme; twist --help ?

@glyph
Copy link
Member Author

glyph commented Oct 22, 2016

Actually it's pretty straightforward. When building the plugin cache, we get the traceback because the txacme endpoint plugin imports twisted.web.client (among other things) that installs the reactor at module scope. Once the cache is built it's fine.

@mithrandi
Copy link
Contributor

Oh, that explains it; I was using a -e install so the plugin cache was already built.

@mithrandi
Copy link
Contributor

So uh... how do we actually fix this?

@mithrandi
Copy link
Contributor

I guess I can move the endpoint parser into its own module, and it can lazily import everything else.

@glyph
Copy link
Member Author

glyph commented Oct 22, 2016

Yeah, plugins just have to be lazy about almost everything. Or we could make Twisted comprehensively forbid importing the reactor at module level :)

@mithrandi mithrandi added this to the 0.9.1 release milestone Oct 26, 2016
@glyph
Copy link
Member Author

glyph commented Oct 27, 2016

Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants