def __init__(self, connection, channel_number, transport=None): # We need to do this before the channel is invoked and send_method is # called CallbackManager.instance().add(channel_number, spec.Channel.OpenOk, transport._on_rpc_complete) Channel.__init__(self, connection, channel_number, None, transport) self.basic_get_ = Channel.basic_get
def __init__(self, parameters=None, on_open_callback=None, reconnection_strategy=None): """ Connection initialization expects a ConnectionParameters object and a callback function to notify when we have successfully connected to the AMQP Broker. A reconnection_strategy of None will use the NullReconnectionStrategy """ self._buffer = "" # Define our callback dictionary self.callbacks = CallbackManager.instance() # On connection callback if on_open_callback: self.add_on_open_callback(on_open_callback) # Set our configuration options self.parameters = parameters or ConnectionParameters() # If we did not pass in a reconnection_strategy, setup the default self.reconnection = reconnection_strategy or NullReconnectionStrategy() # Add our callback for if we close by being disconnected self.add_on_close_callback(self.reconnection.on_connection_closed) # Set all of our default connection state values self._init_connection_state() # Connect to the AMQP Broker self._connect()