def process_initializer(app, hostname): """Initializes the process so it can be used to process tasks.""" app.set_current() set_default_app(app) trace._tasks = app._tasks # make sure this optimization is set. platforms.signals.reset(*WORKER_SIGRESET) platforms.signals.ignore(*WORKER_SIGIGNORE) platforms.set_mp_process_title("celeryd", hostname=hostname) # This is for Windows and other platforms not supporting # fork(). Note that init_worker makes sure it's only # run once per process. app.log.setup(int(os.environ.get("CELERY_LOG_LEVEL", 0)), os.environ.get("CELERY_LOG_FILE") or None, bool(os.environ.get("CELERY_LOG_REDIRECT", False)), str(os.environ.get("CELERY_LOG_REDIRECT_LEVEL"))) app.loader.init_worker() app.loader.init_worker_process() app.finalize() from celery.task.trace import build_tracer for name, task in app.tasks.iteritems(): task.__trace__ = build_tracer(name, task, app.loader, hostname) signals.worker_process_init.send(sender=None)
def process_initializer(app, hostname): """Initializes the process so it can be used to process tasks.""" app.set_current() set_default_app(app) trace._tasks = app._tasks # make sure this optimization is set. platforms.signals.reset(*WORKER_SIGRESET) platforms.signals.ignore(*WORKER_SIGIGNORE) platforms.set_mp_process_title('celeryd', hostname=hostname) # This is for Windows and other platforms not supporting # fork(). Note that init_worker makes sure it's only # run once per process. app.log.setup(int(os.environ.get('CELERY_LOG_LEVEL', 0)), os.environ.get('CELERY_LOG_FILE') or None, bool(os.environ.get('CELERY_LOG_REDIRECT', False)), str(os.environ.get('CELERY_LOG_REDIRECT_LEVEL'))) app.loader.init_worker() app.loader.init_worker_process() app.finalize() from celery.task.trace import build_tracer for name, task in app.tasks.iteritems(): task.__trace__ = build_tracer(name, task, app.loader, hostname) signals.worker_process_init.send(sender=None)
default_app = Proxy(lambda: state.default_app) #: Function returning the app provided or the default app if none. #: #: The environment variable :envvar:`CELERY_TRACE_APP` is used to #: trace app leaks. When enabled an exception is raised if there #: is no active app. app_or_default = None #: The 'default' loader is the default loader used by old applications. default_loader = os.environ.get('CELERY_LOADER') or 'default' #: Global fallback app instance. set_default_app( Celery('default', loader=default_loader, set_as_current=False, accept_magic_kwargs=True)) def bugreport(): return current_app().bugreport() def _app_or_default(app=None): if app is None: return state.get_current_app() return app def _app_or_default_trace(app=None): # pragma: no cover
#: Proxy always returning the app set as default. default_app = Proxy(lambda: state.default_app) #: Function returning the app provided or the default app if none. #: #: The environment variable :envvar:`CELERY_TRACE_APP` is used to #: trace app leaks. When enabled an exception is raised if there #: is no active app. app_or_default = None #: The 'default' loader is the default loader used by old applications. default_loader = os.environ.get("CELERY_LOADER") or "default" #: Global fallback app instance. set_default_app(Celery("default", loader=default_loader, set_as_current=False, accept_magic_kwargs=True)) def bugreport(): return current_app().bugreport() def _app_or_default(app=None): if app is None: return state.get_current_app() return app def _app_or_default_trace(app=None): # pragma: no cover from traceback import print_stack from billiard import current_process