import redis import tasks from pickle import loads q = redis.Redis() while True: f, args = loads(q.blpop("tasks")[1]) getattr(tasks, f)(*args)