-
-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CmdAction calls callable more than once #437
Comments
I just tried to add a |
For my own action subclass to mitigate that, I just call
https://github.com/jgrey4296/doot/blob/master/doot/utils/TaskExt.py |
Just stumbled onto this issue as well.
|
Definitely a bug, though, right? |
Describe the bug
Given a simple
dodo.py
like this:You can see that
action_thing
gets called twice (the print line is run twice). The root cause appears to be thatCmdAction.action
is defined as:so a
self.action
call actually runs the callable. Andself.action
is called in several places. For example, line 283 is:This can be problematic in some circumstances. For example, I have a callable that makes a REST call to get a version number and then uses that to do some other things. Obviously I don't want to make that call twice.
Environment
suggestion: call the callable once and cache the result. A
@functools.cache
might do the trick.The text was updated successfully, but these errors were encountered: