Created
January 26, 2020 06:45
-
-
Save geoffkoh/c45a4dfd26bcc40b7a6ba6a0173b1dbd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExecutorFactory: | |
""" The factory class for creating executors""" | |
registry = {} | |
""" Internal registry for available executors """ | |
@classmethod | |
def register(cls, name: str) -> Callable: | |
def inner_wrapper(wrapped_class: ExecutorBase) -> Callable: | |
if name in cls.registry: | |
logger.warning('Executor %s already exists. Will replace it', name) | |
cls.registry[name] = wrapped_class | |
return wrapped_class | |
return inner_wrapper | |
# end register() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment