MCPcopy
hub / github.com/celery/celery / setup_worker_optimizations

Function setup_worker_optimizations

celery/app/trace.py:792–819  ·  view source on GitHub ↗

Setup worker related optimizations.

(app, hostname=None)

Source from the content-addressed store, hash-verified

790
791
792def setup_worker_optimizations(app, hostname=None):
793 """Setup worker related optimizations."""
794 hostname = hostname or gethostname()
795
796 # make sure custom Task.__call__ methods that calls super
797 # won't mess up the request/task stack.
798 _install_stack_protection()
799
800 # all new threads start without a current app, so if an app is not
801 # passed on to the thread it will fall back to the "default app",
802 # which then could be the wrong app. So for the worker
803 # we set this to always return our app. This is a hack,
804 # and means that only a single app can be used for workers
805 # running in the same process.
806 app.set_current()
807 app.set_default()
808
809 # evaluate all task classes by finalizing the app.
810 app.finalize()
811
812 # set fast shortcut to task registry
813 _localized[:] = [
814 app._tasks,
815 prepare_accept_content(app.conf.accept_content),
816 hostname,
817 ]
818
819 app.use_fast_trace_task = True
820
821
822def reset_worker_optimizations(app=current_app):

Calls 4

set_currentMethod · 0.80
set_defaultMethod · 0.80
finalizeMethod · 0.45