Make at_post_cmd() run after func() also for delayed commands. Resolve #2179
This commit is contained in:
parent
1e5c302e9b
commit
9040aafb05
2 changed files with 23 additions and 10 deletions
|
|
@ -70,6 +70,8 @@ without arguments starts a full interactive Python console.
|
||||||
- Make `INLINEFUNC_STACK_MAXSIZE` default visible in `settings_default.py`.
|
- Make `INLINEFUNC_STACK_MAXSIZE` default visible in `settings_default.py`.
|
||||||
- Change how `ic` finds puppets; non-priveleged users will use `_playable_characters` list as
|
- Change how `ic` finds puppets; non-priveleged users will use `_playable_characters` list as
|
||||||
candidates, Builders+ will use list, local search and only global search if no match found.
|
candidates, Builders+ will use list, local search and only global search if no match found.
|
||||||
|
- Make `cmd.at_post_cmd()` always run after `cmd.func()`, even when the latter uses delays
|
||||||
|
with yield.
|
||||||
|
|
||||||
|
|
||||||
## Evennia 0.9 (2018-2019)
|
## Evennia 0.9 (2018-2019)
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,7 @@ def _progressive_cmd_run(cmd, generator, response=None):
|
||||||
else:
|
else:
|
||||||
value = generator.send(response)
|
value = generator.send(response)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
pass
|
raise
|
||||||
else:
|
else:
|
||||||
if isinstance(value, (int, float)):
|
if isinstance(value, (int, float)):
|
||||||
utils.delay(value, _progressive_cmd_run, cmd, generator)
|
utils.delay(value, _progressive_cmd_run, cmd, generator)
|
||||||
|
|
@ -631,11 +631,22 @@ def cmdhandler(
|
||||||
ret = cmd.func()
|
ret = cmd.func()
|
||||||
if isinstance(ret, types.GeneratorType):
|
if isinstance(ret, types.GeneratorType):
|
||||||
# cmd.func() is a generator, execute progressively
|
# cmd.func() is a generator, execute progressively
|
||||||
|
in_generator = True
|
||||||
|
try:
|
||||||
_progressive_cmd_run(cmd, ret)
|
_progressive_cmd_run(cmd, ret)
|
||||||
|
except StopIteration:
|
||||||
|
# this means func() has run its course
|
||||||
|
in_generator = False
|
||||||
yield None
|
yield None
|
||||||
else:
|
else:
|
||||||
|
in_generator = False
|
||||||
ret = yield ret
|
ret = yield ret
|
||||||
|
|
||||||
|
if not in_generator:
|
||||||
|
# this will only run if we are out of the generator for this
|
||||||
|
# cmd, otherwise we would have at_post_cmd run before a delayed
|
||||||
|
# func() finished
|
||||||
|
|
||||||
# post-command hook
|
# post-command hook
|
||||||
yield cmd.at_post_cmd()
|
yield cmd.at_post_cmd()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue