# Buggy code
def PushItem(self, item, block=True):
    """Push an item on to the queue.

    If no ZeroMQ socket has been created, one will be created the first time
    this method is called.

    Args:
      item: The item to push on to the queue.
      block: Optional argument to indicate whether the push should be performed
             in blocking or non-block mode.

    Raises:
      KeyboardInterrupt: If the process is sent a KeyboardInterrupt while
                         pushing an item.
      zmq.error.Again: If it was not possible to push the item to the queue
                       within the timeout.
      zmq.error.ZMQError: If a ZeroMQ specific error occurs.
    """
    logging.debug("Push on {0:s} queue, port {1:d}".format(self.name, self.port))
    if not self._zmq_socket:
        self._CreateZMQSocket()
    try:
        if block:
            self._zmq_socket.send_pyobj(item)
        else:
            self._zmq_socket.send_pyobj(item, zmq.DONTWAIT)
    except zmq.error.Again:
        logging.error("{0:s} unable to push item, raising.".format(self.name))
        raise
    except zmq.error.ZMQError as exception:
        if exception.errno == errno.EINTR:
            logging.error("ZMQ syscall interrupted in {0:s}.".format(self.name))
            return plaso_queue.QueueAbort()
        else:
            raise
    except KeyboardInterrupt:
        self.Close(abort=True)
        raise


# Traceback (exceptions.AttributeError)
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
File "/usr/lib/python2.7/threading.py", line 763, in run
File "./plaso/engine/zeromq_queue.py", line 651, in _ZeroMQResponder
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'Empty'
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
File "/usr/lib/python2.7/threading.py", line 763, in run
File "./plaso/engine/zeromq_queue.py", line 752, in _ZeroMQResponder
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'Empty'
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
File "/usr/lib/python2.7/threading.py", line 763, in run
File "./plaso/engine/zeromq_queue.py", line 752, in _ZeroMQResponder
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'Empty'
/home/travis/build.sh: line 45:  4478 Segmentation fault      (core dumped) coverage run --source=plaso --omit="*_test*,*__init__*,*test_lib*" ./run_tests.py

# Fixed code
def PushItem(self, item, block=True):
    """Push an item on to the queue.

    If no ZeroMQ socket has been created, one will be created the first time
    this method is called.

    Args:
      item (object): item to push on the queue.
      block (Optional[bool]): whether the push should be performed in blocking
          or non-block mode.

    Raises:
      KeyboardInterrupt: If the process is sent a KeyboardInterrupt while
          pushing an item.
      errors.QueueFull: If it was not possible to push the item to the queue
          within the timeout.
      zmq.error.ZMQError: If a ZeroMQ specific error occurs.
    """
    logging.debug("Push on {0:s} queue, port {1:d}".format(self.name, self.port))
    if not self._zmq_socket:
        self._CreateZMQSocket()

    last_retry_timestamp = time.time() + self.timeout_seconds
    while not self._terminate_event.isSet():
        try:
            send_successful = self._SendItem(self._zmq_socket, item, block)
            if send_successful:
                break

            if time.time() > last_retry_timestamp:
                logging.error("{0:s} unable to push item, raising.".format(self.name))
                raise errors.QueueFull

        except KeyboardInterrupt:
            self.Close(abort=True)
            raise