# 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
            ret = old_method(self, *args, **options)
        finally:
            stop_time = time.time()

            if job:
                job.set_current_io(None)

            if config.get("redis_post_hook"):
                config.get("redis_post_hook")({
                    "command": args[0],
                    "args": args[1:],
                    "options": options,
                    "time": stop_time - start_time,
                    "result": ret,
                    "job": job,
                    "client": self
                })

        return ret


    patch_method(StrictRedis, "execute_command", execute_command)


def patch_io_httplib(config):
    """ Patch the base httplib.HTTPConnection class, which is used in most HTTP libraries
        like urllib2 or urllib3/requests. """

    # pylint: disable=import-error


# 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

            ret = old_method(self, *args, **options)
        finally:
            stop_time = time.time()

            if job:
                job.set_current_io(None)

            if config.get("redis_post_hook"):
                config.get("redis_post_hook")({
                    "command": args[0],
                    "args": args[1:],
                    "options": options,
                    "time": stop_time - start_time,
                    "result": ret,
                    "job": job,
                    "client": self
                })

        return ret


    patch_method(StrictRedis, "execute_command", execute_command)


def patch_io_httplib(config):
    """ Patch the base httplib.HTTPConnection class, which is used in most HTTP libraries
        like urllib2 or urllib3/requests. """

    # pylint: disable=import-error


    def start(method, url):