'Attempts to gracefully shut down the worker thread'

def shutdown(self):

    if (self.parent_pid != os.getpid()):
        return
    else:
        log.info('sending    stop    signal    to    worker    thread')
        self.running = False
        if (not self.app.config.track_jobs_in_database):
            self.queue.put(self.STOP_SIGNAL)
        self.sleeper.wake()
        log.info('job    handler    queue    stopped')
        self.dispatcher.shutdown()
