二、我们在process.start()前将其删除
打开报错文件,twisted/main,文件内容如下:
# -*- test-case-name: twisted.internet.test.test_main -*-
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
Backwards compatibility, and utility functions.
In general, this module should not be used, other than by reactor authors
who need to use the 'installReactor' method.
"""
from twisted.internet import error
CONNECTION_DONE = error.ConnectionDone("Connection done")
CONNECTION_LOST = error.ConnectionLost("Connection lost")
def installReactor(reactor):
"""
Install reactor C{reactor}.
@param reactor: An object that provides one or more IReactor* interfaces.
"""
# this stuff should be common to all reactors.
import sys
import twisted.internet
if "twisted.internet.reactor" in sys.modules:
del sys.modules["twisted.internet.reactor"]
# raise error.ReactorAlreadyInstalledError("reactor already installed")
twisted.internet.reactor = reactor
sys.modules["twisted.internet.reactor"] = reactor
__all__ = ["CONNECTION_LOST", "CONNECTION_DONE", "installReactor"]
将第32行的raise error注释掉,并且删除这个sys就可以解决了,具体代码如下
import sys
if "twisted.internet.reactor" in sys.modules:
del sys.modules["twisted.internet.reactor"]