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

ActorTypeDispatcher Handler Strangeness #85

Open
kevincolyar opened this issue Feb 5, 2025 · 2 comments
Open

ActorTypeDispatcher Handler Strangeness #85

kevincolyar opened this issue Feb 5, 2025 · 2 comments

Comments

@kevincolyar
Copy link

I've been using Thespian for quite a while now and this is the first time I've had to run down an issue like this.

I have a ActorTypeDispatcher actor with the following methods:

    def receiveMsg_Alert(self, alert, _sender):
        logger.warning(f"Alert message received from {_sender} to save: {alert}")

        self.queue.append(alert)
        self.wakeup()

    # TODO: WHY DOES ADDING THIS MAKE receiveMsg_Alert work above?
    def receiveMsg_dict(self, alert, _sender):
        pass

Where the Alert message type is simply:

class Alert(dict):
    pass

For some reason, messages of the Alert type just would not be handled by the first method until I added the _dict handler. Just by chance I added that method to see if the message type wasn't working, but once I did, it started working.

I have several, almost identical actors that have worked for almost 8 years without issue, but this is the first time I've run into this. Ideas?

@kevincolyar kevincolyar changed the title Actor ActorTypeDispatcher Handler Strangeness Feb 5, 2025
@kquick
Copy link
Member

kquick commented Feb 6, 2025

Is it possible that you had an ActorSystem loaded with an older version of whichever Actor was generating the message (as a dict and not an Alert)? Or are your self.wakeup or self.queue affecting things such that the logging message is not delivered?

The logic for ActorTypeDispatcher https://github.com/thespianpy/Thespian/blob/master/thespian/actors.py#L834-L837 will find the first method in "mro" order, so it should have called receiveMsg_Active first, and since that did not return self.SUPER, there should have been no call to receiveMsg_dict.

@kevincolyar
Copy link
Author

The odd thing is that receiveMsg_dict is never called. Just the act of having it defined makes receiveMsg_Alert receive messages. If receiveMsg_dict is commented out or removed, receiveMsg_Alert no longer receives messages.

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

No branches or pull requests

2 participants