jodal / pykka

🌀 Pykka makes it easier to build concurrent Python applications.

Home Page:https://pykka.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dead letters equivalent?

drozzy opened this issue · comments

Is there an equivalent of dead letters in pykka?
I.e. ability to see all the message (at least in a log) that were not delivered anywhere?

Currently, I implement this as follows in my actor:

if message.get('command') == 'poll':
        # logic
else:
        logging.log(logging.DEBUG, 'Dead letters: ' + str(message))

The default implementation of on_receive() in the Actor class will log any unexpected messages on the WARNING log level. If using that, your example could then be updated to:

def on_receive(self, message):
    if message.get('command') == 'poll':
        ... # logic
    else:
        super().on_receive(message)

I'll see if we can improve the docs to include a section on unexpected messages.