def push(self, *objects, args=(), kwargs={}, **options): """Push objects onto the async stack. Arguments: objects {*args of objects} - This can be several objects as parameters into this method. options {**kwargs of options} - Additional options for async driver """ from config.database import DB as schema callback = options.get("callback", "handle") wait = options.get("wait", None) connection = options.get("connection", None) if connection: schema = schema.connection(connection) if wait: wait = parse_human_time(wait).to_datetime_string() for job in objects: if schema.get_schema_builder().has_table("queue_jobs"): payload = pickle.dumps( {"obj": job, "args": args, "kwargs": kwargs, "callback": callback} ) schema.table("queue_jobs").insert( { "name": str(job), "serialized": payload, "created_at": pendulum.now().to_datetime_string(), "attempts": 0, "ran_at": None, "wait_until": wait, } )
def add_to_failed_queue_table(self, payload, driver='amqp'): from config.database import DB as schema from config import queue if 'amqp' in queue.DRIVERS: listening_channel = queue.DRIVERS['amqp']['channel'] else: listening_channel = 'default' if schema.get_schema_builder().has_table('failed_jobs'): schema.table('failed_jobs').insert({ 'driver': driver, 'channel': listening_channel, 'payload': pickle.dumps(payload), 'failed_at': pendulum.now() })
def add_to_failed_queue_table(self, payload, driver="amqp"): from config.database import DB as schema from config import queue if "amqp" in queue.DRIVERS: listening_channel = queue.DRIVERS["amqp"]["channel"] else: listening_channel = "default" if schema.get_schema_builder().has_table("failed_jobs"): schema.table("failed_jobs").insert( { "driver": driver, "channel": listening_channel, "payload": pickle.dumps(payload), "failed_at": pendulum.now(), } )
def push(self, *objects, args=(), kwargs={}, **options): """Push objects onto the async stack. Arguments: objects {*args of objects} - This can be several objects as parameters into this method. options {**kwargs of options} - Additional options for async driver """ from config.database import DB as schema from config import queue callback = options.get('callback', 'handle') wait = options.get('wait', None) connection = options.get('connection', None) if connection: schema = schema.connection(connection) if wait: wait = parse_human_time(wait).to_datetime_string() for job in objects: if schema.get_schema_builder().has_table('queue_jobs'): payload = pickle.dumps({ 'obj': job, 'args': args, 'callback': callback }) schema.table('queue_jobs').insert({ 'name': str(job), 'serialized': payload, 'created_at': pendulum.now().to_datetime_string(), 'attempts': 0, 'ran_at': None, 'wait_until': wait, })