# Path: mrq/context.py
# def get_current_job(greenlet_id=None):
#     if greenlet_id is None:
#         greenlet_id = id(gevent.getcurrent())
#     pair = _GLOBAL_CONTEXT["greenlets"].get(greenlet_id)
#     if not pair:
#         return None
#     return pair[1]
# 
# def get_current_worker():
#     return _GLOBAL_CONTEXT["worker"]


from future import standard_library
from past.builtins import basestring
from .context import get_current_job, get_current_worker
    from termcolor import cprint
    from pymongo.collection import Collection
    from socket import socket as _socketmodule
    from gevent.socket import socket as _geventmodule
    from gevent.ssl import SSLSocket as _sslmodule   # pylint: disable=no-name-in-module
    from redis import StrictRedis
    from http.client import HTTPConnection, HTTPSConnection
        from requests.packages.urllib3.connection import (
            HTTPConnection,
            UnverifiedHTTPSConnection,
            VerifiedHTTPSConnection
        )
        from urllib3.connection import (
            HTTPConnection,
            UnverifiedHTTPSConnection,
            VerifiedHTTPSConnection
        )
    from pymongo.cursor import Cursor
import time
import random
import re
import copy
    import pymongo as pymongomodule
        elif isinstance(seconds, basestring):
            # pylint: disable=maybe-no-member
            if "-" in seconds:
                time.sleep(random.uniform(
                    float(seconds.split("-")[0]),
                    float(seconds.split("-")[1])
                ))
            else:
                time.sleep(float(seconds))

    def _patched_method(old_method, *args, **kwargs):
        sleep()
        return old_method(*args, **kwargs)

    socket_methods = [
        "send", "sendall", "sendto", "recv", "recvfrom", "recvfrom_into", "recv_into",
        "connect", "connect_ex", "close"
    ]


    for method in socket_methods:
        patch_method(_socketmodule, method, _patched_method)
        patch_method(_geventmodule, method, _patched_method)
        patch_method(_sslmodule, method, _patched_method)


def patch_io_redis(config):

    def execute_command(old_method, self, *args, **options):


# Path: mrq/context.py
# def get_current_job(greenlet_id=None):
#     if greenlet_id is None:
#         greenlet_id = id(gevent.getcurrent())
#     pair = _GLOBAL_CONTEXT["greenlets"].get(greenlet_id)
#     if not pair:
#         return None
#     return pair[1]
# 
# def get_current_worker():
#     return _GLOBAL_CONTEXT["worker"]


# Path: mrq/monkey.py
from future import standard_library
from past.builtins import basestring
from .context import get_current_job, get_current_worker
    from termcolor import cprint
    from pymongo.collection import Collection
    from socket import socket as _socketmodule
    from gevent.socket import socket as _geventmodule
    from gevent.ssl import SSLSocket as _sslmodule   # pylint: disable=no-name-in-module
    from redis import StrictRedis
    from http.client import HTTPConnection, HTTPSConnection
        from requests.packages.urllib3.connection import (
            HTTPConnection,
            UnverifiedHTTPSConnection,
            VerifiedHTTPSConnection
        )
        from urllib3.connection import (
            HTTPConnection,
            UnverifiedHTTPSConnection,
            VerifiedHTTPSConnection
        )
    from pymongo.cursor import Cursor
import time
import random
import re
import copy
    import pymongo as pymongomodule

        elif isinstance(seconds, basestring):
            # pylint: disable=maybe-no-member
            if "-" in seconds:
                time.sleep(random.uniform(
                    float(seconds.split("-")[0]),
                    float(seconds.split("-")[1])
                ))
            else:
                time.sleep(float(seconds))

    def _patched_method(old_method, *args, **kwargs):
        sleep()
        return old_method(*args, **kwargs)

    socket_methods = [
        "send", "sendall", "sendto", "recv", "recvfrom", "recvfrom_into", "recv_into",
        "connect", "connect_ex", "close"
    ]


    for method in socket_methods:
        patch_method(_socketmodule, method, _patched_method)
        patch_method(_geventmodule, method, _patched_method)
        patch_method(_sslmodule, method, _patched_method)


def patch_io_redis(config):

    def execute_command(old_method, self, *args, **options):


        job = get_current_job()