mirror of
https://github.com/evennia/evennia.git
synced 2026-04-02 05:57: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
|
|
@ -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