示例#1
0
def main():
    """Celery process entry point.

    Wrap celery command line script with our INI reader.

    .. note ::

        Make sure there is no global app = Celery() in any point of your code base,
        or this doesn't work.

    """
    global ini_file
    global request

    if len(sys.argv) < 2:
        sys.exit("Example usage: ws-celery myapp/conf/development.ini -- worker")

    ini_file = sys.argv[1]
    if not ini_file.endswith(".ini"):
        sys.exit("The first argument must be a configuration file")

    if len(sys.argv) >= 3:
        if not sys.argv[2] == "--":
            raise RuntimeError("The second argument must be -- to signal command line argument passthrough")
        celery_args = sys.argv[3:]
    else:
        celery_args = []

    # https://github.com/celery/celery/issues/3405
    os.environ["CELERY_LOADER"]  = "websauna.system.task.celeryloader.WebsaunaLoader"
    argv = ["celery"] + celery_args
    # Directly jump to Celery 4.0+ entry point
    from celery.bin.celery import main
    main(argv)
示例#2
0
def main(argv: t.List[str]=sys.argv):
    """Celery process entry point.

    Wrap celery command line script with our INI reader.

    .. note ::

        Make sure there is no global app = Celery() in any point of your code base,
        or this doesn't work.

    """
    global ini_file
    global request

    if len(argv) < 2:
        usage_message(argv)

    ini_file = get_config_uri(argv)
    if not ini_file.endswith(".ini"):
        sys.exit("The first argument must be a configuration file")

    if len(argv) >= 3:
        if not argv[2] == "--":
            raise RuntimeError("The second argument must be -- to signal command line argument passthrough")
        celery_args = sys.argv[3:]
    else:
        celery_args = []

    # https://github.com/celery/celery/issues/3405
    os.environ["CELERY_LOADER"]  = "websauna.system.task.celeryloader.WebsaunaLoader"
    argv = ["celery"] + celery_args
    # Directly jump to Celery 4.0+ entry point
    from celery.bin.celery import main
    main(argv)
示例#3
0
def run_celery(argv=sys.argv):
    initialise()
    os.environ['CELERYD_REDIRECT_STDOUTS'] = 'False'
    # technically we don't need this, as we disable celery's logging
    # altogether, but it doesn't hurt
    os.environ['CELERYD_HIJACK_ROOT_LOGGER'] = 'False'
    ensure_extra_versions_supported('celery')
    import talisker.celery
    from celery.bin.celery import main
    talisker.celery.enable_signals()
    main(argv)
示例#4
0
def run_celery(argv=sys.argv):
    initialise()
    os.environ['CELERYD_REDIRECT_STDOUTS'] = 'False'
    # technically we don't need this, as we disable celery's logging
    # altogether, but it doesn't hurt
    os.environ['CELERYD_HIJACK_ROOT_LOGGER'] = 'False'
    ensure_extra_versions_supported('celery')
    import talisker.celery
    from celery.bin.celery import main
    talisker.celery.enable_signals()
    clear_contexts()
    main(argv)
示例#5
0
def run_beat(args):
    os.environ.setdefault("ROLE", 'beat')

    from celery.bin.celery import main
    return main(sys.argv[:1] + [
        '-A', 'hemail',
        'beat',
        '--scheduler', 'django_celery_beat.schedulers:DatabaseScheduler',
    ] + args)
示例#6
0
def run_worker():
    """Starts a celery worker which will """
    from flask import current_app

    print("config", current_app.config)

    main(
        [
            "",
            "-A",
            "taiga2.celery:app",
            "worker",
            "-l",
            "info",
            "-E",
            "-n",
            "worker1@%h",
            "--max-memory-per-child",
            "200000",
        ]
    )
示例#7
0
文件: __main__.py 项目: zzzap/celery
def _compat_beat():
    maybe_patch_concurrency()
    _warn_deprecated('celery beat')
    from celery.bin.beat import main
    main()
示例#8
0
文件: __main__.py 项目: zzzap/celery
def _compat_multi():
    _warn_deprecated('celery multi')
    from celery.bin.multi import main
    main()
from __future__ import absolute_import, print_function, unicode_literals

import sys

from . import maybe_patch_concurrency

__all__ = ['main']


def main():
    if 'multi' not in sys.argv:
        maybe_patch_concurrency()
    from celery.bin.celery import main
    main()


if __name__ == '__main__':  # pragma: no cover
    main()
示例#10
0
文件: __main__.py 项目: frol/celery
def _compat_multi():
    maybe_patch_concurrency()
    maybe_patch_kill()
    _warn_deprecated('celery multi')
    from celery.bin.multi import main
    main()
示例#11
0
def _compat_beat():
    maybe_patch_concurrency()
    from celery.bin.celerybeat import main
    main()
示例#12
0
 def test_main(self, Command):
     command = Command.return_value = Mock()
     main()
     command.execute_from_commandline.assert_called_with()
示例#13
0
def main():
    if 'multi' not in sys.argv:
        maybe_patch_concurrency()
    from celery.bin.celery import main
    main()
示例#14
0
def run_celery(args):
    os.environ.setdefault("ROLE", 'celery')

    from celery.bin.celery import main
    return main(sys.argv[:1] + ['-A', 'hemail', 'worker'] + args)
示例#15
0
 def handle(self, options, global_options, *args):
     from celery.bin import celery
     self.get_application(global_options)
     args = list(args)
     args.insert(0, 'celery')
     celery.main(args)
示例#16
0
from celery.bin.celery import main

main( [ 'main', '-A', 'staging.celery.manager', 'worker', '--concurrency', '1' ] )

示例#17
0
def _compat_worker():
    maybe_patch_concurrency()
    from celery.bin.celeryd import main
    main()
示例#18
0
 def test_main(self, Command):
     command = Command.return_value = Mock()
     main()
     command.execute_from_commandline.assert_called_with(None)
示例#19
0
文件: __main__.py 项目: frol/celery
def main():
    maybe_patch_concurrency()
    maybe_patch_kill()
    from celery.bin.celery import main
    main()
示例#20
0
 def handle(self, *args, **options):
     argv = ["--app=mds_website", "worker", "-l", "info"]
     celery.main(argv)
     
示例#21
0
def _compat_multi():
    maybe_patch_concurrency()
    from celery.bin.celeryd_multi import main
    main()
示例#22
0
def _compat_multi():
    _warn_deprecated('celery multi')
    from celery.bin.multi import main
    main()
示例#23
0
def main():
    maybe_patch_concurrency()
    from celery.bin.celery import main
    main()
示例#24
0
文件: __main__.py 项目: frol/celery
    from celery.bin.celery import main
    main()


def _compat_worker():
    maybe_patch_concurrency()
    maybe_patch_kill()
    _warn_deprecated('celery worker')
    from celery.bin.worker import main
    main()


def _compat_multi():
    maybe_patch_concurrency()
    maybe_patch_kill()
    _warn_deprecated('celery multi')
    from celery.bin.multi import main
    main()


def _compat_beat():
    maybe_patch_concurrency()
    maybe_patch_kill()
    _warn_deprecated('celery beat')
    from celery.bin.beat import main
    main()


if __name__ == '__main__':
    main()
示例#25
0
def _compat_multi():
    maybe_patch_concurrency()
    _warn_deprecated('celery multi')
    from celery.bin.multi import main
    main()
示例#26
0
文件: __main__.py 项目: frol/celery
def _compat_worker():
    maybe_patch_concurrency()
    maybe_patch_kill()
    _warn_deprecated('celery worker')
    from celery.bin.worker import main
    main()
示例#27
0
 def run_from_argv(self, argv):
     from celery.bin.celery import main
     main(self.get_argv(argv))
示例#28
0
文件: __main__.py 项目: frol/celery
def _compat_beat():
    maybe_patch_concurrency()
    maybe_patch_kill()
    _warn_deprecated('celery beat')
    from celery.bin.beat import main
    main()
示例#29
0
文件: __main__.py 项目: zzzap/celery
def _compat_worker():
    maybe_patch_concurrency()
    _warn_deprecated('celery worker')
    from celery.bin.worker import main
    main()
示例#30
0
def main():
    if 'multi' not in sys.argv:
        maybe_patch_concurrency()
    from celery.bin.celery import main
    main()
示例#31
0
from celery.bin import celery

if __name__ == '__main__':
    celery.main()