-
Notifications
You must be signed in to change notification settings - Fork 49
Open
Description
Hey!
A common thing we do for kartons that may hang is to set the task_timeout option in __init__:
from karton.core import Karton
class MyKarton(Karton):
def __init__(self):
self.task_timeout = 10 * 60This works, but it would be cool if karton supported this from cli arguments.
Proposed usage
If my karton has a __main__.py with:
from .my_karton import MyKarton
MyKarton.main()Then I'd like to be able to run:
python3 -m MyKartonSrc --task_timeout 600
Proposed implementation
Following karton-core's code, I believe the flag should be added here:
Lines 148 to 168 in e48d872
| @classmethod | |
| def args_parser(cls) -> argparse.ArgumentParser: | |
| """ | |
| Return ArgumentParser for main() class method. | |
| This method should be overridden and call super methods | |
| if you want to add more arguments. | |
| """ | |
| parser = argparse.ArgumentParser(description=cls.args_description()) | |
| parser.add_argument( | |
| "--version", action="version", version=cast(str, cls.version) | |
| ) | |
| parser.add_argument("--config-file", help="Alternative configuration path") | |
| parser.add_argument( | |
| "--identity", help="Alternative identity for Karton service" | |
| ) | |
| parser.add_argument("--log-level", help="Logging level of Karton logger") | |
| parser.add_argument( | |
| "--debug", help="Enable debugging mode", action="store_true", default=None | |
| ) | |
| return parser |
And added as well here:
Lines 170 to 186 in e48d872
| @classmethod | |
| def config_from_args(cls, config: Config, args: argparse.Namespace) -> None: | |
| """ | |
| Updates configuration with settings from arguments | |
| This method should be overridden and call super methods | |
| if you want to add more arguments. | |
| """ | |
| config.load_from_dict( | |
| { | |
| "karton": { | |
| "identity": args.identity, | |
| "debug": args.debug, | |
| }, | |
| "logging": {"level": args.log_level}, | |
| } | |
| ) |
Metadata
Metadata
Assignees
Labels
No labels