def METHOD_NAME(sender, **_kwargs):  # pragma: no cover
    """Set up the celery worker with one-time initialisation."""
    # Put some common handy things around for tasks
    try:
        lms = create_app(None, **{})
    except Exception:  # pylint: disable=broad-except
        # If we don't bail out here ourselves, Celery just hides the error
        # and continues. This means `request_context` will not be available
        # when attempting to run tasks, which is impossible to debug.
        LOG.critical("CELERY WORKER DID NOT START: Could not create app", exc_info=True)
        sys.exit(1)
    @contextmanager
    def request_context():
        with prepare(registry=lms.registry) as env:
            request = env["request"]
            # Make Pyramid things like route_url() and static_url() use the
            # right hostname and port when called by Celery tasks.
            request.environ["HTTP_HOST"] = os.environ["HTTP_HOST"]
            yield request
    sender.app.request_context = request_context