Conversation
- Import os and multiprocessing in app/celery.py - Add _bind_worker_process_context helper to set pid and worker_id in structlog - Update worker_process_init to bind process context - Update task_prerun and task_postrun to re-bind process context after log.clear() - Resolves TODO in app/celery.py and improves debuggability of worker logs. Co-authored-by: iloveitaly <150855+iloveitaly@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
This PR enriches Celery logs with the current process ID and worker name (e.g., ForkPoolWorker-8).
Changes:
_bind_worker_process_contextinapp/celery.pythat bindspidandworker_idto thestructlogcontext.worker_process_initto initialize the context for new worker processes.on_task_prerunandon_task_postrunto re-bind this context because the existinglog.clear()calls wipe out the worker-level context.Verification:
ruffwas used for static analysis and passed.PR created automatically by Jules for task 8655463301281973614 started by @iloveitaly