Added inlineCallback operator for cmdhandler, allowing the system to yield more often.

This commit is contained in:
Griatch 2012-02-20 21:40:28 +01:00
parent c4f2c493d9
commit 641d829154
3 changed files with 63 additions and 43 deletions

View file

@ -69,12 +69,15 @@ class CmdQuell(MuxCommand):
self.caller.player.user.is_superuser = False
self.caller.player.user.save()
try:
ret = self.caller.execute_cmd(cmd)
except Exception, e:
self.caller.msg(str(e))
def callback(ret):
self.caller.msg(ret)
def errback(err):
self.caller.msg(err)
# this returns a deferred, so we need to assign callbacks
self.caller.execute_cmd(cmd).addCallbacks(callback, errback)
self.caller.permissions = oldperm
self.caller.player.user.is_superuser = old_superuser
self.caller.player.user.save()
return ret
return