mirror of
https://github.com/evennia/evennia.git
synced 2026-03-30 12:37:16 +02:00
Removed func_parts looping from cmdhandler - it didn't work as expected, as shown in #438. Instead reworked utils.delay() to implement the same functionality explicitly.
This commit is contained in:
parent
393a3e5e73
commit
6ea4125ef1
2 changed files with 10 additions and 16 deletions
|
|
@ -399,14 +399,6 @@ def cmdhandler(called_by, raw_string, testing=False, callertype="session", sessi
|
|||
# (return value is normally None)
|
||||
ret = yield cmd.func()
|
||||
|
||||
if hasattr(cmd, "func_parts"):
|
||||
# yield on command parts (for multi-part delayed commands)
|
||||
for func_part in make_iter(cmd.func_parts):
|
||||
err = yield func_part()
|
||||
# returning anything but a deferred/None will kill the chain
|
||||
if err:
|
||||
break
|
||||
|
||||
# post-command hook
|
||||
yield cmd.at_post_cmd()
|
||||
|
||||
|
|
|
|||
|
|
@ -485,24 +485,26 @@ def uses_database(name="sqlite3"):
|
|||
return engine == "django.db.backends.%s" % name
|
||||
|
||||
|
||||
def delay(delay=2, retval=None, callback=None):
|
||||
def delay(delay=2, callback=None, retval=None):
|
||||
"""
|
||||
Delay the return of a value.
|
||||
Inputs:
|
||||
delay (int) - the delay in seconds
|
||||
retval (any) - this will be returned by this function after a delay
|
||||
callback (func(retval)) - if given, this will be called with retval
|
||||
after delay seconds
|
||||
callback (func() or func(retval)) - if given, will be called without
|
||||
arguments or with retval after delay seconds
|
||||
retval (any) - this will be returned by this function after a delay,
|
||||
or as input to callback
|
||||
Returns:
|
||||
deferred that will fire with callback after delay seconds. Note that
|
||||
if delay() is used in the commandhandler callback chain, the callback
|
||||
chain can be defined directly in the command body and don't need to be
|
||||
specified here.
|
||||
"""
|
||||
d = defer.Deferred()
|
||||
callb = callback or d.callback
|
||||
reactor.callLater(delay, callb, retval)
|
||||
return d
|
||||
callb = callback or defer.Deferred().callback
|
||||
if retval is not None:
|
||||
return reactor.callLater(delay, callb, retval)
|
||||
else:
|
||||
return reactor.callLater(delay, callb)
|
||||
|
||||
|
||||
_TYPECLASSMODELS = None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue