def autodiscover_modules(packages, related_name_re='<STR_LIT>',<EOL>ignore_exceptions=False):
warnings.warn('<STR_LIT>'<EOL>'<STR_LIT>', DeprecationWarning)<EOL>global _RACE_PROTECTION<EOL>if _RACE_PROTECTION:<EOL><INDENT>return []<EOL><DEDENT>_RACE_PROTECTION = True<EOL>modules = []<EOL>try:<EOL><INDENT>tmp = [find_related_modules(pkg, related_name_re, ignore_exceptions)<EOL>for pkg in packages]<EOL>for l in tmp:<EOL><INDENT>for m in l:<EOL><INDENT>if m is not None:<EOL><INDENT>modules.append(m)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>except:<EOL><INDENT>_RACE_PROTECTION = False<EOL>raise<EOL><DEDENT>_RACE_PROTECTION = False<EOL>return modules<EOL>
Autodiscover function follows the pattern used by Celery.

    :param packages: List of package names to auto discover modules in.
    :type packages: list of str
    :param related_name_re: Regular expression used to match modules names.
    :type related_name_re: str
    :param ignore_exceptions: Ignore exception when importing modules.
    :type ignore_exceptions: bool