Skip to content

Result retrieval from groups/pipelines only work for the default broker #564

@DiegoPomares

Description

@DiegoPomares

Issues

GitHub issues are for bugs. If you have questions, please ask them on the mailing list.

Checklist

  • Does your title concisely summarize the problem?
  • Did you include a minimal, reproducible example?
  • What OS are you using?
  • What version of Dramatiq are you using?
  • What did you do?
  • What did you expect would happen?
  • What happened?

What OS are you using?

Linux Mint 21.2 Victoria

What version of Dramatiq are you using?

1.14.2

What did you do?

Retrieving results with get_results() from a group, where the group was declared with a specific broker, and it isn't using the global/default one.
I modified the groups and pipelines to looks for the result in the backend of the broker they were declared with, with this it works as expected. Here goes the PR with the proposed changes: #563

What did you expect would happen?

I expected that the group retrieved the result from the backend of the broker it was declared with.

What happened?

I get the following error: RuntimeError: The default broker doesn't have a results backend.

Minimal reproducible example

import dramatiq
from dramatiq.brokers.redis import RedisBroker
from dramatiq.results.backends import RedisBackend
from dramatiq.results import Results


@dramatiq.actor
def add(x, y):
    return x + y


REDIS_URL = "redis://127.0.0.1:6379/0"

backend = RedisBackend(url=REDIS_URL)
results = Results(backend=backend, store_results=True)

broker = RedisBroker(url=REDIS_URL)
broker.add_middleware(results)
broker.declare_actor(add)


if __name__ == "__main__":
    group = dramatiq.group(
        broker=broker,
        children=[
            add.send(1, 1),
            add.send(2, 2),
        ]
    )
    group.run()

    results = list(group.get_results(block=True))  # RuntimeError!
    print(results)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions