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

UnboundLocalError encounter in _WorkerThread #382

Closed
TariqAHassan opened this issue Feb 10, 2021 · 5 comments
Closed

UnboundLocalError encounter in _WorkerThread #382

TariqAHassan opened this issue Feb 10, 2021 · 5 comments

Comments

@TariqAHassan
Copy link

TariqAHassan commented Feb 10, 2021

Issues

An UnboundLocalError can be encountered in _WorkerThread.

Checklist

What OS are you using?

Ubuntu 18.04

What version of Dramatiq are you using?

v1.10.0

What did you do?

Worker thread attempted to process a message.

What did you expect would happen?

Actor to be defined.

What happened?

It's possible for an UnboundLocalError to be encountered in dramatiq/worker.py in the _WorkerThread.process_message() method. The relevant piece of code is:

        try:
            self.logger.debug("Received message %s with id %r.", message, message.message_id)
            self.broker.emit_before("process_message", message)

            res = None
            if not message.failed:
                actor = self.broker.get_actor(message.actor_name)
            ...

        except SkipMessage:
            self.logger.warning("Message %s was skipped.", message)
            self.broker.emit_after("skip_message", message)

        except BaseException as e:
            ...
            throws = message.options.get("throws") or actor.options.get("throws")
...

That is, if actor = self.broker.get_actor(message.actor_name) does not run, actor will not be defined below.

@Bogdanp
Copy link
Owner

Bogdanp commented Feb 11, 2021

Interesting! Do you know what the original error was?

@TariqAHassan
Copy link
Author

Hey Bogdanp.

Thanks for the fast reply.

I do not, unfortunately. However, an exception in self.broker.emit_before() could precipitate this problem.

@ashleybartlett
Copy link

@Bogdanp any chance of getting this in a release soon?

@Bogdanp
Copy link
Owner

Bogdanp commented May 22, 2021

@ashleybartlett I just released 1.11.

@ashleybartlett
Copy link

Thank you @Bogdanp !

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

No branches or pull requests

3 participants