# Path: mrq/context.py
# def setup_context(**kwargs):
#     """ Setup MRQ's environment.
# 
#         Note: gevent should probably be initialized too if you want to use concurrency.
#     """
#     set_current_config(get_config(**kwargs))
# 
# Path: mrq/job.py
# def queue_jobs(main_task_path, params_list, queue=None, batch_size=1000):
#     """ Queue multiple jobs on a regular queue """
#     if len(params_list) == 0:
#         return []
#     if queue is None:
#         task_def = context.get_current_config().get("tasks", {}).get(main_task_path) or {}
#         queue = task_def.get("queue", "default")
# 
#     from .queue import Queue
#     queue_obj = Queue(queue)
# 
#     if queue_obj.is_raw:
#         raise Exception("Can't queue regular jobs on a raw queue")
# 
#     all_ids = []
# 
#     for params_group in group_iter(params_list, n=batch_size):
# 
#         context.metric("jobs.status.queued", len(params_group))
# 
#         # Insert the job in MongoDB
#         job_ids = Job.insert([{
#             "path": main_task_path,
#             "params": params,
#             "queue": queue,
#             "datequeued": datetime.datetime.utcnow(),
#             "status": "queued"
#         } for params in params_group], w=1, return_jobs=False)
# 
#         all_ids += job_ids
# 
#     queue_obj.notify(len(all_ids))
#     set_queues_size({queue: len(all_ids)})
# 
#     return all_ids
# 
# def queue_raw_jobs(queue, params_list, **kwargs):
#     """ Queue some jobs on a raw queue """
# 
#     from .queue import Queue
#     queue_obj = Queue(queue)
#     queue_obj.enqueue_raw_jobs(params_list, **kwargs)
#     # No need to store queue size as we already have a fast way to get raw queue size


import sys
from mrq.context import setup_context
from mrq.job import queue_jobs, queue_raw_jobs
#!/usr/bin/env python

setup_context()

queue = sys.argv[1]
n = int(sys.argv[2])


# Path: mrq/context.py
# def setup_context(**kwargs):
#     """ Setup MRQ's environment.
# 
#         Note: gevent should probably be initialized too if you want to use concurrency.
#     """
#     set_current_config(get_config(**kwargs))
# 
# Path: mrq/job.py
# def queue_jobs(main_task_path, params_list, queue=None, batch_size=1000):
#     """ Queue multiple jobs on a regular queue """
#     if len(params_list) == 0:
#         return []
#     if queue is None:
#         task_def = context.get_current_config().get("tasks", {}).get(main_task_path) or {}
#         queue = task_def.get("queue", "default")
# 
#     from .queue import Queue
#     queue_obj = Queue(queue)
# 
#     if queue_obj.is_raw:
#         raise Exception("Can't queue regular jobs on a raw queue")
# 
#     all_ids = []
# 
#     for params_group in group_iter(params_list, n=batch_size):
# 
#         context.metric("jobs.status.queued", len(params_group))
# 
#         # Insert the job in MongoDB
#         job_ids = Job.insert([{
#             "path": main_task_path,
#             "params": params,
#             "queue": queue,
#             "datequeued": datetime.datetime.utcnow(),
#             "status": "queued"
#         } for params in params_group], w=1, return_jobs=False)
# 
#         all_ids += job_ids
# 
#     queue_obj.notify(len(all_ids))
#     set_queues_size({queue: len(all_ids)})
# 
#     return all_ids
# 
# def queue_raw_jobs(queue, params_list, **kwargs):
#     """ Queue some jobs on a raw queue """
# 
#     from .queue import Queue
#     queue_obj = Queue(queue)
#     queue_obj.enqueue_raw_jobs(params_list, **kwargs)
#     # No need to store queue size as we already have a fast way to get raw queue size


# Path: examples/queue_performance/enqueue.py
import sys
from mrq.context import setup_context
from mrq.job import queue_jobs, queue_raw_jobs

#!/usr/bin/env python

setup_context()

queue = sys.argv[1]
n = int(sys.argv[2])


if queue == "square":