<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _wait_receive_msg(self, timeout=0.25, type=2):
 """Internal helper that will wait for new messages of a given type, and throw an exception on timeout"""

        stamp = time.monotonic()
        while (time.monotonic() - stamp) < timeout:
            try:
                message = self._mq.receive(block=False, type=2)
                return message
            except sysv_ipc.BusyError:
                time.sleep(0.001) # wait a bit then retry!
        # uh-oh timed out
        raise RuntimeError("Timed out waiting for PulseIn message")