Skip to content

Timers registered in worker boot are getting cancelled on consumer close #7844

Closed

Description

@meensu23

Discussed in #7843

Originally posted by meensu23 October 21, 2022
I register some timers during worker start

class WorkerBoot(bootsteps.StartStopStep):
    requires = {"celery.worker.components:Pool",
                "celery.worker.components:Timer"}
    ...
    def __init__(self, worker, **kwargs) -> None:
    def start(self, worker):
        ...
        worker.timer.call_repeatedly(
            self.state_refresh_interval,
            self.some_function,
            (worker,),
            priority=10,
        )
    ...

What I observe is after a connection loss (with amq) and restart the above timer does not fire.

I printed the timer ref above and I see the same timer ref being used in worker and consumer. And as per

self.timer.clear()
I see the timer is being cleared.

consumerboot consumer.timer=<kombu.asynchronous.timer.Timer object at 0x7f819d7bfbe0>
workerboot worker.timer=<kombu.asynchronous.timer.Timer object at 0x7f819d7bfbe0>

Does worker and consumer use the same timer - documentation seem to suggest they use different (https://docs.celeryq.dev/en/stable/userguide/extending.html?highlight=consumer%20boot#id8).

What timer should I be using in the worker?

Activity

  1. open-collective-bot commented on Oct 21, 2022

    @open-collective-bot

    Hey @meensu23 👋,
    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.

  2. changed the title [-]Timers registered in worker start are getting cancelled on consumer close[/-] [+]Timers registered in worker boot are getting cancelled on consumer close[/+] on Oct 26, 2022
  3. meensu23 commented on Oct 26, 2022

    @meensu23
    Author

    @auvipy - is this a celery issue or the way I use it?

  4. modified the milestones: 5.7.x, 5.7.0 on Oct 22, 2026
  5. auvipy commented on Oct 22, 2026

    @auvipy
    Member

    closing as per #10888 (comment)

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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions