<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _emulated(self, timeout=None):
 """Get the next message avaiable in the queue. :returns: The message and the name of the queue it came from as a tuple. :raises Empty: If there are no more items in any of the queues. """


        # A set of queues we've already tried.
        tried = set()

        while True:
            # Get the next queue in the cycle, and try to get an item off it.
            try:
                queue = self.cycle.next()
            except StopIteration:
                raise Empty("No queues registered")
            try:
                item = queue.get()
            except Empty:
                # raises Empty when we've tried all of them.
                tried.add(queue.name)
                if tried == self.all:
                    raise
            else:
                return item, queue.name