def add_synchronous_cb(self, cb):
        '''
        Add an expectation of a callback to release a synchronous transaction.
        '''
        if self.connection.synchronous or self._synchronous:
            wrapper = SyncWrapper(cb)
            self._pending_events.append(wrapper)
            while wrapper._read:
                # Don't check that the channel has been closed until after
                # reading frames, in the case that this is processing a clean
                # channel closed. If there's a protocol error during
                # read_frames, this will loop back around and result in a
                # channel closed exception.
                if self.closed:
                    if self.close_info and \
                            len(self.close_info['reply_text']) > 0:
                        raise ChannelClosed(
                            "channel %d is closed: %s : %s",
                            self.channel_id,
                            self.close_info['reply_code'],
                            self.close_info['reply_text'])
                    raise ChannelClosed()
                self.connection.read_frames()

            return wrapper._result
        else:
            self._pending_events.append(cb)
def add_synchronous_cb ( self , cb ) : if self . connection . synchronous or self . _synchronous : wrapper = SyncWrapper ( cb ) self . _pending_events . append ( wrapper ) while wrapper . _read : if self . closed : if self . close_info and len ( self . close_info [ 'reply_text' ] ) > 0 : raise ChannelClosed ( "channel %d is closed: %s : %s" , self . channel_id , self . close_info [ 'reply_code' ] , self . close_info [ 'reply_text' ] ) raise ChannelClosed ( ) self . connection . read_frames ( ) return wrapper . _result else : self . _pending_events . append ( cb )
Add an expectation of a callback to release a synchronous transaction.