Skip to content

Instantly share code, notes, and snippets.

@geoffkoh
Created January 26, 2020 06:45
Show Gist options
  • Save geoffkoh/c45a4dfd26bcc40b7a6ba6a0173b1dbd to your computer and use it in GitHub Desktop.
Save geoffkoh/c45a4dfd26bcc40b7a6ba6a0173b1dbd to your computer and use it in GitHub Desktop.
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