code: def PopItem(self):
      
      if not self._zmq_socket:
        self._CreateZMQSocket()
  
      if not self._closed_event or not self._terminate_event:
        raise RuntimeError('Missing closed or terminate event.')
  
      logger.debug(
          'Pop on {0:s} queue, port {1:d}'.format(self.name, self.port))
  
      last_retry_timestamp = time.time() + self.timeout_seconds
      while not self._closed_event.is_set() or not self._terminate_event.is_set():
        try:
          return self._ReceiveItemOnActivity(self._zmq_socket)
  
        except errors.QueueEmpty:
          if time.time() > last_retry_timestamp:
            raise
  
        except KeyboardInterrupt:
          self.Close(abort=True)
          raise
docs: Pops an item off the queue.
  
      If no ZeroMQ socket has been created, one will be created the first
      time this method is called.
  
      Returns:
        object: item from the queue.
  
      Raises:
        KeyboardInterrupt: if the process is sent a KeyboardInterrupt while
            popping an item.
        QueueEmpty: if the queue is empty, and no item could be popped within the
            queue timeout.
        RuntimeError: if closed or terminate event is missing.
        zmq.error.ZMQError: if a ZeroMQ error occurs.