def queue_daemon(app, rv_ttl=500):
    print 'Mancing commencing...'
    while 1:
        msg = redis.blpop(app.config['REDIS_QUEUE_KEY'])
        func, key, args, kwargs = loads(msg[1])
        try:
            rv = func(*args, **kwargs)
            rv = {'status': 'ok', 'result': rv}
        except Exception, e:
            if client:
                client.captureException()
            tb = traceback.format_exc()
            print tb
            try:
                if e.body:
                    rv = {'status': 'error', 'result': '{0} message: {1}'.format(e.message, e.body)}
                else:
                    rv = {'status': 'error', 'result': e.message}
            except __HOLE__:
                rv = {'status': 'error', 'result': 'Error: {0}'.format(e.message)}
        if rv is not None:
            redis.set(key, dumps(rv))
            redis.expire(key, rv_ttl)
dataset/ETHPy150Open associatedpress/geomancer/geomancer/worker.py/queue_daemon