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

Fixed the problem of AsyncAioPikaManager repeatedly creating a connec… #692

Closed
wants to merge 1 commit into from

Conversation

wangjianweiwei
Copy link

No description provided.

@wangjianweiwei
Copy link
Author

This is my first time to contribute code😄. give me some advice.

return queue
def initialize(self):
loop = asyncio.get_event_loop()
loop.create_task(self._initialize())
Copy link
Owner

@miguelgrinberg miguelgrinberg May 26, 2021

Choose a reason for hiding this comment

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

This is a really strange way to initialize. It is also bound to race conditions, since you also call _initialize() in the _listen() method. I mean, I understand why you are doing it, but it isn't a robust solution, I think.

Copy link
Author

Choose a reason for hiding this comment

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

What do you suggest? I want to do this well.

channel = await self._channel(connection)
exchange = await self._exchange(channel)
await exchange.publish(
await self.listener_exchange.publish(
Copy link
Owner

Choose a reason for hiding this comment

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

This will fail if the connection to the queue breaks and needs to be re-established. The Redis manage, which is the one that the vast majority of people use, has connection retries, maybe we want that here as well?

self.listener_channel, exchange
)
retry_sleep = 1
await self._initialize()
Copy link
Owner

Choose a reason for hiding this comment

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

This is problematic, because you have one more _initialize() call above. Both will set the same variables.

@miguelgrinberg
Copy link
Owner

Given the lack of response and the fact that this PR is now outdated, I will close it. Please open a new PR and address my feedback if you want me to add this.

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