# ==================================================================================
# Copyright (c) 2019 Nokia
# Copyright (c) 2018-2019 AT&T Intellectual Property.
# ==================================================================================
# Copyright (c) 2019 Nokia
# Copyright (c) 2018-2019 AT&T Intellectual Property.
# Mnemonic: helpers.py
# Abstract: This is a collection of extensions to the RMR base package
# which are likely to be convenient for Python programs.
# Mnemonic: helpers.py
# Abstract: This is a collection of extensions to the RMR base package
# which are likely to be convenient for Python programs.
"""
Assembles an array of all messages which can be received without blocking
(but see the timeout parameter). Effectively drains the message queue if
RMR is started in mt-call mode, or draining any waiting TCP buffers. If
the pass_filter parameter is supplied, it is treated as one or more
message types to accept (pass through). Using the default, an empty list,
"""
Assembles an array of all messages which can be received without blocking
(but see the timeout parameter). Effectively drains the message queue if
RMR is started in mt-call mode, or draining any waiting TCP buffers. If
the pass_filter parameter is supplied, it is treated as one or more
message types to accept (pass through). Using the default, an empty list,
- results in capturing all messages. if the timeout parameter is supplied,
- this call may block up to that number of milliseconds waiting for a
- message to arrive. Using the default, zero, results in non-blocking
- no-wait behavior.
+ results in capturing all messages. If the timeout parameter is supplied
+ and is not zero, this call may block up to that number of milliseconds
+ waiting for a message to arrive. Using the default, zero, results in
+ non-blocking no-wait behavior.
mbuf = rmr.rmr_torcv_msg(mrc, mbuf, timeout) # first call may have non-zero timeout
timeout = 0 # reset so subsequent calls do not wait
summary = rmr.message_summary(mbuf)
mbuf = rmr.rmr_torcv_msg(mrc, mbuf, timeout) # first call may have non-zero timeout
timeout = 0 # reset so subsequent calls do not wait
summary = rmr.message_summary(mbuf)
"""
Same as rmr_rcvall_msgs, but answers tuples with the raw sbuf.
Useful if return-to-sender (rts) functions are required.
"""
Same as rmr_rcvall_msgs, but answers tuples with the raw sbuf.
Useful if return-to-sender (rts) functions are required.
mbuf = rmr.rmr_torcv_msg(mrc, mbuf, timeout) # first call may have non-zero timeout
timeout = 0 # reset so subsequent calls do not wait
summary = rmr.message_summary(mbuf)
mbuf = rmr.rmr_torcv_msg(mrc, mbuf, timeout) # first call may have non-zero timeout
timeout = 0 # reset so subsequent calls do not wait
summary = rmr.message_summary(mbuf)
new_messages.append((summary, mbuf)) # caller is responsible for freeing the buffer
else:
rmr.rmr_free_msg(mbuf) # free the filtered-out message buffer
new_messages.append((summary, mbuf)) # caller is responsible for freeing the buffer
else:
rmr.rmr_free_msg(mbuf) # free the filtered-out message buffer