'Returns a scanned barcode. Will wait at most 5 seconds to get a barcode, and will
return barcode scanned in the past if they are not older than 5 seconds and have not
been returned before. This is necessary to catch barcodes scanned while the POS is
busy reading another barcode'

def get_barcode(self):

    self.lockedstart()
    while True:
        try:
            (timestamp, barcode) = self.barcodes.get(True, 5)
            if (timestamp > (time.time() - 5)):
                return barcode
        except Empty:
            return ''
