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

Refactor to support Async consumers #67

Merged
merged 10 commits into from
Feb 3, 2025
Merged

Conversation

NeonDaniel
Copy link
Member

@NeonDaniel NeonDaniel commented Jan 20, 2025

Description

Refactors MQ handling to use a connector class, similar to other services
Adds unit test coverage for new connector
Update dependencies

Issues

Other Notes

Currently deployed to https://iris.neonaialpha.com/

Add `ready` property to check IrisConnector status
Update dependencies
Resolve unit test failure
Add test coverage for `IrisConnector`
@NeonDaniel NeonDaniel changed the title Make use of async MQ consumers configurable Refactor to support Async consumers Jan 25, 2025
@NeonDaniel NeonDaniel marked this pull request as ready for review January 25, 2025 00:57
@NeonDaniel NeonDaniel requested a review from mikejgray January 25, 2025 01:10
def wait_for_connection(self):
LOG.info("Waiting for connection")
while not self._ready.is_set():
sleep(0.5)
Copy link
Contributor

Choose a reason for hiding this comment

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

Sleep isn't thread safe, is it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, probably not. I think the issue I ran into with run(self._ready.wait()) is that somehow the event would be set, but wait would not return. This was really more of a temporary workaround, so I will look into how to fix this

Copy link
Member Author

Choose a reason for hiding this comment

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

Upon further investigation, the issue appears related to the SelectConnection using its own IOLoop. I tried passing a specific EventLoop, but that is apparently incompatible with pika. I settled on a working solution that still uses sleep, but does use the connection's ioloop which I believe makes that thread safe..

Looking back, I'm not sure this is functionally different than what was originally there and sleep isn't threadsafe, but it probably doesn't have to be in the current implementation since the even't we're checking is threadsafe..

@NeonDaniel NeonDaniel requested a review from mikejgray January 29, 2025 01:37
@NeonDaniel NeonDaniel merged commit df7ceb1 into dev Feb 3, 2025
7 checks passed
@NeonDaniel NeonDaniel deleted the FEAT_UseAsyncMqConnections branch February 3, 2025 23:03
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