mirror of
https://github.com/django/daphne.git
synced 2024-11-25 01:03:45 +03:00
Try to uninstall previous reactors if they're found
This commit is contained in:
parent
3b5721c699
commit
7949b244b8
|
@ -1,6 +1,15 @@
|
||||||
# This has to be done first as Twisted is import-order-sensitive with reactors
|
# This has to be done first as Twisted is import-order-sensitive with reactors
|
||||||
|
import sys # isort:skip
|
||||||
|
import warnings # isort:skip
|
||||||
from twisted.internet import asyncioreactor # isort:skip
|
from twisted.internet import asyncioreactor # isort:skip
|
||||||
asyncioreactor.install() # isort:skip
|
if "twisted.internet.reactor" in sys.modules:
|
||||||
|
warnings.warn(
|
||||||
|
"Something has already installed a Twisted reactor. Attempting to uninstall it; ",
|
||||||
|
"you can fix this warning by importing daphne.server early in your codebase or ",
|
||||||
|
"finding the package that imports Twisted and importing it later on."
|
||||||
|
)
|
||||||
|
del sys.modules["twisted.internet.reactor"]
|
||||||
|
asyncioreactor.install()
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
Loading…
Reference in New Issue
Block a user