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

fix: raise ChannelInvalidStateError at exchange.publish with closed channel #637

Merged
merged 2 commits into from
Aug 5, 2024

Conversation

Lancetnik
Copy link
Contributor

@coveralls
Copy link

coveralls commented Jul 12, 2024

Coverage Status

coverage: 88.327% (+0.01%) from 88.316%
when pulling 4e93dc4 on Lancetnik:master
into 9c1ee8f on mosquito:master.

@mosquito mosquito requested review from decaz and mosquito July 18, 2024 08:57
raise aiormq.exceptions.ChannelInvalidStateError(
"%r closed" % self.channel,
)

channel = await self.channel.get_underlay_channel()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't channel closure checked in this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, it is waiting for channel readiness forewer

Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you mean waiting here?

async def get_underlay_channel(self) -> aiormq.abc.AbstractChannel:
await self._connection.ready()
return await super().get_underlay_channel()

There is waiting for connection readiness - not for channel readiness, and in the test you are closing connection, not channel. Maybe in publish method should be checked connection (not channel) and aiormq.exceptions.ConnectionClosed exception raised?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure, that is correct. I just followed the aiormq exceptions style. Also, connection and channel and quite closely related, so they can be open/closed both only. I am checking channel due it is the most important thing for we functionality. Can @mosquito resolve the dispute?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can change the code without any problems and basically agree with your points, but not sure about the person, who makes the final decision about PR merging

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Anyway, we have no access to self.channel._connection object due it is RobustChannel-class attribute only. So, we should check self.channel to be compatible with any AbstractChannel implementation

raise aiormq.exceptions.ChannelInvalidStateError(
"%r closed" % self.channel,
)

channel = await self.channel.get_underlay_channel()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you mean waiting here?

async def get_underlay_channel(self) -> aiormq.abc.AbstractChannel:
await self._connection.ready()
return await super().get_underlay_channel()

There is waiting for connection readiness - not for channel readiness, and in the test you are closing connection, not channel. Maybe in publish method should be checked connection (not channel) and aiormq.exceptions.ConnectionClosed exception raised?

@@ -339,6 +339,34 @@ async def test_simple_publish_and_receive_to_bound_exchange(

await queue.unbind(dest_exchange, routing_key)

async def test_simple_publish_with_closed_channel(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't it be called "test_simple_publish_with_closed_connection" ?

@decaz decaz self-requested a review August 4, 2024 12:43
@mosquito mosquito merged commit f41c28c into mosquito:master Aug 5, 2024
9 checks passed
@gaby
Copy link

gaby commented Aug 13, 2024

@Lancetnik This was released to day with v9.4.3

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