# Path: mrq/context.py
# _GLOBAL_CONTEXT = {
# 
#     # Contains all the running greenlets for this worker. greenletid => Job object
#     "greenlets": {},
# 
#     # pointer to the current worker
#     "worker": None,
# 
#     # pointer to the current config
#     "config": {}
# }
# def setup_context(**kwargs):
# def set_current_job(job):
# def get_current_job(greenlet_id=None):
# def set_current_worker(worker):
# def get_current_worker():
# def set_logger_config():
# def set_current_config(config):
# def get_current_config():
# def retry_current_job(delay=None, max_retries=None, queue=None):
# def abort_current_job():
# def _connections_factory(attr):
#     def versiontuple(v):
# def enable_greenlet_tracing():
#     def trace(*args):
# def run_task(path, params):
# def set_current_job_progress(ratio, save=False):
# def queue_raw_jobs(*args, **kwargs):
# def queue_job(*args, **kwargs):
# def queue_jobs(*args, **kwargs):
# def metric(*args, **kwargs):


from builtins import range
from mrq.context import connections
import time
import pytest

    worker.start_deps(flush=True)

    worker.send_task(
        "tests.tasks.general.MongoInsert", {"a": 41, "sleep": 1}, queue="q1", block=False, start=False)
    worker.send_task(
        "tests.tasks.general.MongoInsert", {"a": 42, "sleep": 1}, queue="q2", block=False, start=False)
    worker.send_task(
        "tests.tasks.general.MongoInsert", {"a": 43, "sleep": 1}, queue="q1", block=False, start=False)
    worker.send_task(
        "tests.tasks.general.MongoInsert", {"a": 44, "sleep": 1}, queue="q2", block=False, start=False)
    worker.send_task(
        "tests.tasks.general.MongoInsert", {"a": 45, "sleep": 1}, queue="q3", block=False, start=False)

    time.sleep(0.5)

    flags = "--greenlets %s" % p_greenlets
    if p_strategy:
        flags += " --dequeue_strategy %s" % p_strategy

    print("Worker has flags %s" % flags)
    worker.start(flags=flags, queues="q1 q2", deps=False, block=False)

    gotit = worker.wait_for_idle(timeout=10)

    if p_strategy == "burst":
        assert not gotit  # because worker should be stopped already
    else:
        assert gotit


# Path: mrq/context.py
# _GLOBAL_CONTEXT = {
# 
#     # Contains all the running greenlets for this worker. greenletid => Job object
#     "greenlets": {},
# 
#     # pointer to the current worker
#     "worker": None,
# 
#     # pointer to the current config
#     "config": {}
# }
# def setup_context(**kwargs):
# def set_current_job(job):
# def get_current_job(greenlet_id=None):
# def set_current_worker(worker):
# def get_current_worker():
# def set_logger_config():
# def set_current_config(config):
# def get_current_config():
# def retry_current_job(delay=None, max_retries=None, queue=None):
# def abort_current_job():
# def _connections_factory(attr):
#     def versiontuple(v):
# def enable_greenlet_tracing():
#     def trace(*args):
# def run_task(path, params):
# def set_current_job_progress(ratio, save=False):
# def queue_raw_jobs(*args, **kwargs):
# def queue_job(*args, **kwargs):
# def queue_jobs(*args, **kwargs):
# def metric(*args, **kwargs):


# Path: tests/test_parallel.py
from builtins import range
from mrq.context import connections
import time
import pytest


    worker.start_deps(flush=True)

    worker.send_task(
        "tests.tasks.general.MongoInsert", {"a": 41, "sleep": 1}, queue="q1", block=False, start=False)
    worker.send_task(
        "tests.tasks.general.MongoInsert", {"a": 42, "sleep": 1}, queue="q2", block=False, start=False)
    worker.send_task(
        "tests.tasks.general.MongoInsert", {"a": 43, "sleep": 1}, queue="q1", block=False, start=False)
    worker.send_task(
        "tests.tasks.general.MongoInsert", {"a": 44, "sleep": 1}, queue="q2", block=False, start=False)
    worker.send_task(
        "tests.tasks.general.MongoInsert", {"a": 45, "sleep": 1}, queue="q3", block=False, start=False)

    time.sleep(0.5)

    flags = "--greenlets %s" % p_greenlets
    if p_strategy:
        flags += " --dequeue_strategy %s" % p_strategy

    print("Worker has flags %s" % flags)
    worker.start(flags=flags, queues="q1 q2", deps=False, block=False)

    gotit = worker.wait_for_idle(timeout=10)

    if p_strategy == "burst":
        assert not gotit  # because worker should be stopped already
    else:
        assert gotit


    inserts = list(connections.mongodb_jobs.tests_inserts.find(sort=[("_id", 1)]))