def initialize(): """ This imports all packages that are descendant of this package, and, after that, it register all subclases of service provider as """ import os.path import pkgutil import sys from uds.core import jobs from uds.core.managers.TaskManager import TaskManager # Dinamycally import children of this package. pkgpath = os.path.dirname(sys.modules[__name__].__file__) for _, name, _ in pkgutil.iter_modules([pkgpath]): logger.debug('Importing {}'.format(name)) __import__(name, globals(), locals(), [], 1) p = jobs.Job # This is marked as error in IDE, but it's not (__subclasses__) for cls in p.__subclasses__(): logger.debug('Examining worker {}'.format(cls.__module__)) # Limit to autoregister just workers jobs inside this module if cls.__module__[0:16] == 'uds.core.workers': logger.debug('Added worker {} to list'.format(cls.__module__)) TaskManager.registerJob(cls)