Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit signal.worker_init in prefork pool child process #7573

Open
4 tasks done
milos-u opened this issue Jun 15, 2022 · 3 comments
Open
4 tasks done

Emit signal.worker_init in prefork pool child process #7573

milos-u opened this issue Jun 15, 2022 · 3 comments

Comments

@milos-u
Copy link

milos-u commented Jun 15, 2022

Checklist

  • I have checked the issues list
    for similar or identical enhancement to an existing feature.
  • I have checked the pull requests list
    for existing proposed enhancements.
  • I have checked the commit log
    to find out if the if the same enhancement was already implemented in the
    master branch.
  • I have included all related issues and possible duplicate issues in this issue
    (If there are none, check this box anyway).

Related Issues and Possible Duplicates

Related Issues

  • None

Possible Duplicates

  • None

Brief Summary

From my manual observation, child process from the prefork pool does not emit signal.worker_init under Windows when starting.

With this patch:

--- a/celery/concurrency/prefork.py
+++ b/celery/concurrency/prefork.py
@@ -78,6 +78,7 @@ def process_initializer(app, hostname):
                                       app=app)
     from celery.worker import state as worker_state
     worker_state.reset_state()
+    signals.worker_init.send(sender=None)
     signals.worker_process_init.send(sender=None)

first the Django worker_fixup is installed (in worker_init signal callback) and then Django fixup on_worker_process_init is called (in worker_process_init signal callback).

Without this patch, Django is not initialized inside the child process (django.setup() is not called).

Design

Architectural Considerations

None

Proposed Behavior

Proposed UI/UX

Diagrams

N/A

Alternatives

None

@open-collective-bot
Copy link

Hey @milos-u 👋,
Thank you for opening an issue. We will get back to you as soon as we can.
Also, check out our Open Collective and consider backing us - every little helps!

We also offer priority support for our sponsors.
If you require immediate assistance please consider sponsoring us.

@auvipy
Copy link
Member

auvipy commented Jun 16, 2022

can you come with proposed patch with an integration & unit test?

@milos-u
Copy link
Author

milos-u commented Jun 29, 2022

I can try, right now a lot of work elsewhere, will take a look at it.

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

No branches or pull requests

2 participants