Skip to content

Notifier restart #2030

Open
Open

Description

@mdabrowski1990

Is your feature request related to a problem? Please describe.

After I call can.notifier.Notifier.stop not a Notifier object, there is no obvious way how to restart the Notifier.
As far as I see, I need to create a new notifier, which leads to another problem - if a Bus is added to two Notifiers (even if one of them is stopped) then an exception is raised by can.notifier._NotifierRegistry.register.

Describe the solution you'd like

I would like a restart method defined in Notifier class which would work exactly like I just created a new Notifier with the exactly the same settings as the existing one.

Describe alternatives you've considered

  • can.notifier._NotifierRegistry.register does not raise an exception if another Notifier is stopped

Activity

  1. zariiii9003 commented on Feb 22, 2026

    @zariiii9003
    Collaborator

    Notifier._registry.unregister(bus, self) is called at the end of Notifier.stop():

    Notifier._registry.unregister(bus, self)

    Did you get some exception before that line?

    Edit: The exception is raised only if the Notifier is not stopped:

    if bus is pair.bus and not pair.notifier.stopped:

    Use Notifier.find_instances() to debug.

  2. mdabrowski1990 commented on Feb 23, 2026

    @mdabrowski1990
    Author

    It is possible that exception with bus collision was my coding mistake.
    Yet, I would appreciate you could add restart Notifier feature though.

  3. gravesmiOSU commented on May 11, 2026

    @gravesmiOSU

    Added a pull request that contains this feature request and some new testing to potentially address. Hope this helps.

  4. zariiii9003 commented on Jun 6, 2026

    @zariiii9003
    Collaborator

    @gravesmiOSU I saw your PR, but i think stopping and restarting the Notifier will cause too many problems. Calling Notifier.stop() also calls the stop method of the listeners, which causes resources to be closed and cleaned up. Also the receive buffer of the bus will overflow.

    I think something like pause() and unpause() could work (although i don't like the names), where the incoming messages are just dismissed in Notifier._on_message_received.

    @mdabrowski1990 what do you think?

  5. mdabrowski1990 commented on Jun 8, 2026

    @mdabrowski1990
    Author

    @gravesmiOSU I saw your PR, but i think stopping and restarting the Notifier will cause too many problems. Calling Notifier.stop() also calls the stop method of the listeners, which causes resources to be closed and cleaned up. Also the receive buffer of the bus will overflow.

    I think something like pause() and unpause() could work (although i don't like the names), where the incoming messages are just dismissed in Notifier._on_message_received.

    @mdabrowski1990 what do you think?

    Sounds great. Thank you!

  6. mdabrowski1990 commented on Aug 30, 2026

    @mdabrowski1990
    Author

    I also noticed that:

    • can.listener.Listener has stop method, but no resume / restart / unpause
    • can.listener.AsyncBufferedReader does not have exposed _is_stopped attribute (it can be stopped, but there is no good way to check whether it happened)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions