Skip to content

fix consumer destroy #141

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chandr-andr
Copy link

@chandr-andr chandr-andr commented Apr 19, 2023

Hello! Thank you for your awesome project!
I found two problems with the consumer shutdown.

Firstly, there is an error if you want to destroy consumer, but you decided to use the method fetch instead of consume:

AttributeError: 'Consumer' object has no attribute 't_consume'

It occurs because this variable will be set only if the client-side application calls consume.

Secondly, if you are using the generate_random_suffix parameter for consumer constructor await memphis.consumer(generate_random_suffix=True, ...) memphis add a key with name without suffix in consumer name - self.consumers_map[map_key] = consumer, map_key here is default name without suffix, so, when consumer tries to destroy an error occurs:

memphis.exceptions.MemphisError: memphis: 'taskiq_test_taskiq_consume_135a4cea'

Error is Implicit but I found that error was raised here:

# consumer, line 189
del self.connection.consumers_map[map_key]

@chandr-andr chandr-andr changed the title Added new code to fix consumer destroy fix consumer destroy Apr 20, 2023
@idanasulin2706
Copy link
Contributor

Hi @chandr-andr thanks for the fixes, we will test it ASAP and keep you updated

@chandr-andr
Copy link
Author

@idanasulinmemphis Thank you)

@@ -505,6 +505,7 @@ async def consumer(
real_name = consumer_name.lower()
if generate_random_suffix:
consumer_name = self.__generateRandomSuffix(consumer_name)
real_name += "_" + consumer_name.split("_")[-1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is wrong since real name is the consumer name without the suffix which is the desired behavior

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, but it breaks consumer shutdown, I'll find another way to fix it soon.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks, waiting for that

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

Successfully merging this pull request may close these issues.

2 participants