def worker(buffer, n, offset, mod, process_packet):
    """
    Worker process used in multiprocessing mode
    """

    def update_timer():
        global _timer

        if (time.time() - os.stat(config.TRAILS_FILE).st_mtime) >= config.UPDATE_PERIOD:
            _ = None
            while True:
                _ = load_trails(True)
                if _:
                    trails.clear()
                    trails.update(_)
                    break
                else:
                    time.sleep(LOAD_TRAILS_RETRY_SLEEP_TIME)

        _timer = threading.Timer(config.UPDATE_PERIOD, update_timer)
        _timer.start()

    update_timer()

    count = 0
    while True:
        try:
            if (count % mod) == offset:
                if count >= n.value:
                    time.sleep(REGULAR_SENSOR_SLEEP_TIME)
                    continue

                content = read_block(buffer, count)

                if content is None:
                    break

                elif len(content) < 12:
                    continue

                sec, usec, ip_offset = struct.unpack("=III", content[:12])
                packet = content[12:]
                process_packet(packet, sec, usec, ip_offset)

            count += 1

        except KeyboardInterrupt:
            break

    if _timer:
        _timer.cancel()

    Worker process used in multiprocessing mode
    
core/parallel.py