Skip to content

Signals : celeryd_after_setup called with sender but not worker_process_init #1972

Closed

Description

@NotSqrt

Hi!

https://github.com/celery/celery/blob/master/celery/apps/worker.py#L157:

        signals.celeryd_after_setup.send(
            sender=self.hostname, instance=self, conf=self.app.conf,
        )

https://github.com/celery/celery/blob/master/celery/concurrency/prefork.py#L82:

def process_initializer(app, hostname):
    # ...
    signals.worker_process_init.send(sender=None)

The hostname is indeed available in the method that sends the signal, which is not the case for the worker_process_shutdown signal.

I'm just wondering why the hostname is not passed as sender for this signal..

Activity

  1. ask commented on Apr 16, 2014

    @ask
    Contributor

    I don't know, I cannot think of any obvious reason why the sender should be the hostname, it could just as easily be the pid, or the app.

    Most likely the reason is that the hostname was not even available at the time when the signal was introduced in 2.0:
    https://github.com/celery/celery/blob/2.0-archived/celery/worker/__init__.py#L34-L55

  2. FabianEnvoy commented on Jul 26, 2017

    @FabianEnvoy

    Hi,

    i am facing a usecase where knowing the sender (or worker_pool_name) from which a process is started is needed to decide how the worker_process is initialized. Some workers are responsible for database I/O and need to know a global db_connection variable while others are only working with local information. Right now it is only possible to setup one prozess-initialization for all worker pools...

    or am I missing a feature/function?

    best regards

    Fabian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions