Skip to content
Discussion options

You must be logged in to vote

This happens because Client.__init__() creates an instance attribute with the same name:

self.connection_lost_callback = None

That instance attribute shadows your subclass method named connection_lost_callback, so later lookup finds None, not the method on your subclass. The reconnect path then checks/calls the instance attribute, so the subclass method is never reached.

Use assignment after super().__init__() instead:

from asyncua import Client

class MyClient(Client):
    def __init__(self, url):
        super().__init__(url)
        self.connection_lost_callback = self._on_connection_lost

    async def _on_connection_lost(self, exc):
        print("connection lost:", exc)

Two detail…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@iamthebull
Comment options

Answer selected by iamthebull
Comment options

You must be logged in to vote
1 reply
@iamthebull
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants