Remove channelhandler

This commit is contained in:
Griatch 2021-05-08 15:43:41 +02:00
parent f5fd398480
commit a95d801b1e
12 changed files with 61 additions and 468 deletions

View file

@ -117,7 +117,11 @@ def check_errors(settings):
"Use PORTAL/SERVER_LOG_DAY_ROTATION and PORTAL/SERVER_LOG_MAX_SIZE "
"to control log cycling."
)
if hasattr(settings, "CHANNEL_COMMAND_CLASS") or hasaattr(settings, "CHANNEL_HANDLER_CLASS"):
raise DeprecationWarning(
"settings.CHANNEL_HANDLER_CLASS and CHANNEL COMMAND_CLASS are "
"unused and should be removed. The ChannelHandler is no more; "
"channels are now handled by aliasing the default 'channel' command.")
def check_warnings(settings):
"""

View file

@ -131,10 +131,9 @@ def create_channels():
goduser = get_god_account()
channel_mudinfo = settings.CHANNEL_MUDINFO
if not channel_mudinfo:
raise RuntimeError("settings.CHANNEL_MUDINFO must be defined.")
channel = create.create_channel(**channel_mudinfo)
channel.connect(goduser)
if channel_mudinfo:
channel = create.create_channel(**channel_mudinfo)
channel.connect(goduser)
channel_connectinfo = settings.CHANNEL_CONNECTINFO
if channel_connectinfo:

View file

@ -36,7 +36,6 @@ from evennia.server.models import ServerConfig
from evennia.utils.utils import get_evennia_version, mod_import, make_iter
from evennia.utils import logger
from evennia.comms import channelhandler
from evennia.server.sessionhandler import SESSIONS
from django.utils.translation import gettext as _
@ -143,9 +142,6 @@ def _server_maintenance():
if _MAINTENANCE_COUNT % 5 == 0:
# check cache size every 5 minutes
_FLUSH_CACHE(_IDMAPPER_CACHE_MAXSIZE)
if _MAINTENANCE_COUNT % 61 == 0:
# validate channels off-sync with scripts
evennia.CHANNEL_HANDLER.update()
if _MAINTENANCE_COUNT % (60 * 7) == 0:
# drop database connection every 7 hrs to avoid default timeouts on MySQL
# (see https://github.com/evennia/evennia/issues/1376)
@ -202,12 +198,6 @@ class Evennia:
self.start_time = time.time()
# initialize channelhandler
try:
channelhandler.CHANNELHANDLER.update()
except OperationalError:
print("channelhandler couldn't update - db not set up")
# wrap the SIGINT handler to make sure we empty the threadpool
# even when we reload and we have long-running requests in queue.
# this is necessary over using Twisted's signal handler.
@ -544,11 +534,10 @@ class Evennia:
god_account = AccountDB.objects.get(id=1)
# mudinfo
mudinfo_chan = settings.CHANNEL_MUDINFO
if not mudinfo_chan:
raise RuntimeError("settings.CHANNEL_MUDINFO must be defined.")
if not ChannelDB.objects.filter(db_key=mudinfo_chan["key"]):
channel = create_channel(**mudinfo_chan)
channel.connect(god_account)
if mudinfo_chan:
if not ChannelDB.objects.filter(db_key=mudinfo_chan["key"]):
channel = create_channel(**mudinfo_chan)
channel.connect(god_account)
# connectinfo
connectinfo_chan = settings.CHANNEL_MUDINFO
if connectinfo_chan:

View file

@ -57,41 +57,6 @@ class TestServer(TestCase):
self.server._server_maintenance()
mocks["_FLUSH_CACHE"].assert_called_with(1000)
def test__server_maintenance_validate_scripts(self):
with patch.multiple(
"evennia.server.server",
LoopingCall=DEFAULT,
Evennia=DEFAULT,
_FLUSH_CACHE=DEFAULT,
connection=DEFAULT,
_IDMAPPER_CACHE_MAXSIZE=1000,
_MAINTENANCE_COUNT=60 - 1,
_LAST_SERVER_TIME_SNAPSHOT=0,
ServerConfig=DEFAULT,
) as mocks:
mocks["connection"].close = MagicMock()
mocks["ServerConfig"].objects.conf = MagicMock(return_value=100)
self.server._server_maintenance()
mocks["_FLUSH_CACHE"].assert_called_with(1000)
def test__server_maintenance_channel_handler_update(self):
with patch.multiple(
"evennia.server.server",
LoopingCall=DEFAULT,
Evennia=DEFAULT,
_FLUSH_CACHE=DEFAULT,
connection=DEFAULT,
_IDMAPPER_CACHE_MAXSIZE=1000,
_MAINTENANCE_COUNT=61 - 1,
_LAST_SERVER_TIME_SNAPSHOT=0,
ServerConfig=DEFAULT,
) as mocks:
mocks["connection"].close = MagicMock()
mocks["ServerConfig"].objects.conf = MagicMock(return_value=100)
with patch("evennia.server.server.evennia.CHANNEL_HANDLER.update") as mock:
self.server._server_maintenance()
mock.assert_called()
def test__server_maintenance_close_connection(self):
with patch.multiple(
"evennia.server.server",