diff --git a/evennia/commands/cmdhandler.py b/evennia/commands/cmdhandler.py index aaa4bcdd85..d7183b5f6c 100644 --- a/evennia/commands/cmdhandler.py +++ b/evennia/commands/cmdhandler.py @@ -36,7 +36,7 @@ from traceback import format_exc from django.conf import settings from django.utils.translation import gettext as _ from twisted.internet import reactor -from twisted.internet.defer import inlineCallbacks +from twisted.internet.defer import Deferred, inlineCallbacks from twisted.internet.task import deferLater from evennia.commands.cmdset import CmdSet @@ -251,6 +251,9 @@ def _progressive_cmd_run(cmd, generator, response=None): utils.delay(value, _progressive_cmd_run, cmd, generator) elif isinstance(value, str): _GET_INPUT(cmd.caller, value, _process_input, cmd=cmd, generator=generator) + elif isinstance(value, Deferred): + value.addCallback(lambda result: _progressive_cmd_run(cmd, generator, response=result)) + value.addErrback(lambda fail: generator.throw(fail.type, fail.value, fail.tb)) else: raise ValueError("unknown type for a yielded value in command: {}".format(type(value))) diff --git a/evennia/commands/default/unloggedin.py b/evennia/commands/default/unloggedin.py index a69e20068e..0cd2fe37aa 100644 --- a/evennia/commands/default/unloggedin.py +++ b/evennia/commands/default/unloggedin.py @@ -8,11 +8,11 @@ import re from codecs import lookup as codecs_lookup from django.conf import settings +from twisted.internet import threads import evennia from evennia.commands.cmdhandler import CMD_LOGINSTART -from evennia.comms.models import ChannelDB -from evennia.utils import class_from_module, create, gametime, logger, utils +from evennia.utils import class_from_module, gametime, utils COMMAND_DEFAULT_CLASS = utils.class_from_module(settings.COMMAND_DEFAULT_CLASS) @@ -146,8 +146,8 @@ class CmdUnconnectedConnect(COMMAND_DEFAULT_CLASS): Account = class_from_module(settings.BASE_ACCOUNT_TYPECLASS) name, password = parts - account, errors = Account.authenticate( - username=name, password=password, ip=address, session=session + account, errors = yield threads.deferToThread( + Account.authenticate, username=name, password=password, ip=address, session=session ) if account: session.sessionhandler.login(session, account) @@ -227,8 +227,8 @@ class CmdUnconnectedCreate(COMMAND_DEFAULT_CLASS): return # everything's ok. Create the new player account. - account, errors = Account.create( - username=username, password=password, ip=address, session=session + account, errors = yield threads.deferToThread( + Account.create, username=username, password=password, ip=address, session=session ) if account: # tell the caller everything went well.