Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_basic_nack_send_method_request(self, send_method, _unused):
self.obj._set_state(self.obj.OPEN)
self.obj.basic_nack(1, False, True)
send_method.assert_called_once_with(spec.Basic.Nack(1, False, True))
def on_cancelled(self, frame):
self.assertIsInstance(frame.method, spec.Basic.CancelOk)
self.stop()
def on_cancelled(self, frame):
self.assertIsInstance(frame.method, spec.Basic.CancelOk)
self.stop()
def on_delivery_confirmation(frame):
global last_ack_time, pending_messages, pos_acks, neg_acks, last_ack, count, total
if isinstance(frame.method, spec.Basic.Ack) or isinstance(frame.method, spec.Basic.Nack):
if frame.method.multiple == True:
acks = 0
messages_to_remove = [item for item in pending_messages if item <= frame.method.delivery_tag]
for val in messages_to_remove:
try:
pending_messages.remove(val)
except:
print(f"Could not remove multiple flag message: {val}")
acks += 1
else:
try:
pending_messages.remove(frame.method.delivery_tag)
except:
print(f"Could not remove non-multiple flag message: {frame.method.delivery_tag}")
acks = 1
0x00280028: Exchange.Unbind,
0x00280033: Exchange.UnbindOk,
0x0032000A: Queue.Declare,
0x0032000B: Queue.DeclareOk,
0x00320014: Queue.Bind,
0x00320015: Queue.BindOk,
0x0032001E: Queue.Purge,
0x0032001F: Queue.PurgeOk,
0x00320028: Queue.Delete,
0x00320029: Queue.DeleteOk,
0x00320032: Queue.Unbind,
0x00320033: Queue.UnbindOk,
0x003C000A: Basic.Qos,
0x003C000B: Basic.QosOk,
0x003C0014: Basic.Consume,
0x003C0015: Basic.ConsumeOk,
0x003C001E: Basic.Cancel,
0x003C001F: Basic.CancelOk,
0x003C0028: Basic.Publish,
0x003C0032: Basic.Return,
0x003C003C: Basic.Deliver,
0x003C0046: Basic.Get,
0x003C0047: Basic.GetOk,
0x003C0048: Basic.GetEmpty,
0x003C0050: Basic.Ack,
0x003C005A: Basic.Reject,
0x003C0064: Basic.RecoverAsync,
0x003C006E: Basic.Recover,
0x003C006F: Basic.RecoverOk,
0x003C0078: Basic.Nack,
0x005A000A: Tx.Select,
0x005A000B: Tx.SelectOk,
def on_delivery_confirmation(frame):
global last_ack_time, pending_messages, pos_acks, neg_acks, last_ack, count
if isinstance(frame.method, spec.Basic.Ack) or isinstance(frame.method, spec.Basic.Nack):
if frame.method.multiple == True:
acks = 0
messages_to_remove = [item for item in pending_messages if item <= frame.method.delivery_tag]
for val in messages_to_remove:
try:
pending_messages.remove(val)
except:
print(f"Could not remove multiple flag message: {val}")
acks += 1
else:
try:
pending_messages.remove(frame.method.delivery_tag)
except:
print(f"Could not remove non-multiple flag message: {frame.method.delivery_tag}")
acks = 1
def _on_puback_message_returned(self, channel, method, properties, body):
"""Called as the result of Basic.Return from broker in
publisher-acknowledgements mode. Saves the info as a ReturnedMessage
instance in self._puback_return.
:param pika.Channel channel: our self._impl channel
:param pika.spec.Basic.Return method:
:param pika.spec.BasicProperties properties: message properties
:param bytes body: returned message body; empty string if no body
"""
assert channel is self._impl, (channel.channel_number,
self.channel_number)
assert isinstance(method, pika.spec.Basic.Return), method
assert isinstance(properties, pika.spec.BasicProperties), (properties)
LOGGER.warning(
"Published message was returned: _delivery_confirmation=%s; "
"channel=%s; method=%r; properties=%r; body_size=%d; "
"body_prefix=%.255r", self._delivery_confirmation,
channel.channel_number, method, properties,
len(body) if body is not None else None, body)
self._puback_return = ReturnedMessage(method, properties, body)
0x0032001E: Queue.Purge,
0x0032001F: Queue.PurgeOk,
0x00320028: Queue.Delete,
0x00320029: Queue.DeleteOk,
0x00320032: Queue.Unbind,
0x00320033: Queue.UnbindOk,
0x003C000A: Basic.Qos,
0x003C000B: Basic.QosOk,
0x003C0014: Basic.Consume,
0x003C0015: Basic.ConsumeOk,
0x003C001E: Basic.Cancel,
0x003C001F: Basic.CancelOk,
0x003C0028: Basic.Publish,
0x003C0032: Basic.Return,
0x003C003C: Basic.Deliver,
0x003C0046: Basic.Get,
0x003C0047: Basic.GetOk,
0x003C0048: Basic.GetEmpty,
0x003C0050: Basic.Ack,
0x003C005A: Basic.Reject,
0x003C0064: Basic.RecoverAsync,
0x003C006E: Basic.Recover,
0x003C006F: Basic.RecoverOk,
0x003C0078: Basic.Nack,
0x005A000A: Tx.Select,
0x005A000B: Tx.SelectOk,
0x005A0014: Tx.Commit,
0x005A0015: Tx.CommitOk,
0x005A001E: Tx.Rollback,
0x005A001F: Tx.RollbackOk,
0x0055000A: Confirm.Select,
0x0055000B: Confirm.SelectOk
def on_delivery_confirmation(self, frame):
if isinstance(frame.method, spec.Basic.Ack) or isinstance(frame.method, spec.Basic.Nack):
if frame.method.multiple == True:
acks = 0
messages_to_remove = [item for item in self.pending_messages if item <= frame.method.delivery_tag]
for val in messages_to_remove:
try:
self.pending_messages.remove(val)
if isinstance(frame.method, spec.Basic.Ack) and val in self.msg_map:
self.msg_set.add(self.msg_map[val])
except:
console_out(f"Could not remove multiple flag message: {val}", self.get_actor())
acks += 1
else:
try:
self.pending_messages.remove(frame.method.delivery_tag)
if isinstance(frame.method, spec.Basic.Ack) and frame.method.delivery_tag in self.msg_map:
self.msg_set.add(self.msg_map[frame.method.delivery_tag])
self._current_future = futurist.Future()
self._execute_task(self._impl.basic_publish,
exchange=exchange,
routing_key=routing_key,
body=body,
properties=properties,
mandatory=mandatory,
immediate=immediate)
conf_method = self._current_future.result().method
if isinstance(conf_method, pika_spec.Basic.Nack):
raise pika_exceptions.NackError((None,))
else:
assert isinstance(conf_method, pika_spec.Basic.Ack), (
conf_method)
if self._message_returned:
raise pika_exceptions.UnroutableError((None,))
else:
# In non-publisher-acknowledgments mode
self._execute_task(self._impl.basic_publish,
exchange=exchange,
routing_key=routing_key,
body=body,
properties=properties,
mandatory=mandatory,
immediate=immediate)