Created
September 12, 2020 13:36
-
-
Save gaufung/23b363d7acae0c1f828d3a3fdbffb5d2 to your computer and use it in GitHub Desktop.
rabbitmq_asynchronous_channel.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _create_channel(self, connection): | |
self.logger.info("creating channel") | |
future = Future() | |
def on_channel_closed(channel, reply_code, reply_txt): | |
if reply_code not in [self._NORMAL_CLOSE_CODE, self._USER_CLOSE_CODE]: | |
self.logger.error("channel closed. reply code: %s; reply text: %s. system will exist" | |
% (reply_code, reply_txt,)) | |
sys.exit(self._EXIST_CODE) | |
def open_callback(channel): | |
self.logger.info("created channel") | |
channel.add_on_close_callback(on_channel_closed) | |
future.set_result(channel) | |
connection.channel(on_open_callback=open_callback) | |
return future |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment