-
Notifications
You must be signed in to change notification settings - Fork 192
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
Add example of reopening channels that have been closed #364
base: master
Are you sure you want to change the base?
Conversation
4c80718
to
38893c7
Compare
Thanks @Sinkler for catching that. I found that I actually needed some more infrastructure around this to work properly since channels were attempting to reinitialize queues and exchanges on reopen. I've changed my commit to make sure things look good. |
async def reopen(self) -> None: | ||
# Clear out exchanges and queues when reopened | ||
self._exchanges = defaultdict(set) | ||
self._queues = defaultdict(set) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, we had some memory leaks with set
so we replaced it by WeakSet
in the __init__
method and now it's ok 🙃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the info! I will make those same changes...
@mosquito the py35/py36-uvloop tox tests are failing, but I'm not sure what to do about those. They appear to be unrelated to my PR. |
@mosquito I have updated the PR if you could take a look again. Thanks! |
Ran across this again, any chance of getting it merged @mosquito? |
@bluesliverx ouch, I should be write this comment earlier, but doesn't sorry. I completely do not understand why I will want to apply this example in real project when to be honest. When you want do not reconnecting when the underlay-connection faills you shouldn't use |
@mosquito, I do want the robust connection since I want it to re-established. However, I do not want the queues and exchanges to be declared again since some of them are exclusive and cannot be recreated by a new connection. I believe rabbit threw errors in that case. As for why I need the |
This bit me recently when channels were closed unexpectedly due to long running message retrieval on an API where client connections were closed suddenly. This apparently put the channels in a bad state (
ChannelInvalidStateError("writer is None")
to be exact), and therefore I had to check channels when retrieving them from the pool.