Module Import alias Import alias Import alias Import alias Assign NameStore ListLoad Str Str Str Str Str Str Assign NameStore Set Str Str Str Assign NameStore Call AttributeLoad NameLoad attr Str ClassDef bases body Expr Str FunctionDef arguments args NameParam NameParam defaults TupleLoad body Expr Str Assign AttributeStore NameLoad attr Dict Expr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults vararg body Expr Str For NameStore NameLoad body Assign SubscriptStore AttributeLoad NameLoad attr Index NameLoad Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str TryFinally body For TupleStore NameStore NameStore Call AttributeLoad AttributeLoad NameLoad attr attr body If CompareIsNot NameLoad NameLoad body Assign SubscriptStore AttributeLoad NameLoad attr Index NameLoad NameLoad orelse TryExcept body Delete SubscriptDel AttributeLoad NameLoad attr Index NameLoad handlers ExceptHandler type NameLoad body Pass finalbody Expr Call AttributeLoad NameLoad attr decorator_list decorator_list FunctionDef arguments args NameParam NameParam defaults vararg body Expr Str Assign NameStore BinOpAdd Str NameLoad If CompareIn NameLoad AttributeLoad NameLoad attr body Return SubscriptLoad AttributeLoad NameLoad attr Index NameLoad If UnaryOpNot NameLoad body Assign NameStore BinOpAdd BinOpAdd BinOpAdd BinOpAdd Call NameLoad Call NameLoad Call NameLoad Call NameLoad Call NameLoad Assign NameStore Call NameLoad ListComp NameLoad comprehension TupleStore NameStore NameStore NameLoad Expr Call AttributeLoad NameLoad attr NameLoad For TupleStore NameStore NameStore NameLoad body Assign SubscriptStore AttributeLoad NameLoad attr Index NameLoad NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad TryFinally body Assign NameStore Call NameLoad NameLoad Dict Dict SubscriptLoad Call AttributeLoad NameLoad attr Str Slice Num If CompareIsNot NameLoad NameLoad body For NameStore Call NameLoad NameLoad body If CompareNotIn NameLoad NameLoad body Assign SubscriptStore NameLoad Index NameLoad Call NameLoad NameLoad NameLoad Assign SubscriptStore AttributeLoad NameLoad attr Index NameLoad NameLoad finalbody Expr Call AttributeLoad NameLoad attr Return NameLoad decorator_list FunctionDef arguments args NameParam defaults vararg kwarg body Expr Str Return Call NameLoad NameLoad NameLoad BinOpAdd NameLoad Call NameLoad Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults vararg body Expr Str If UnaryOpNot NameLoad body Assign NameStore BinOpAdd BinOpAdd BinOpAdd BinOpAdd Call NameLoad Call NameLoad Call NameLoad Call NameLoad Call NameLoad FunctionDef arguments args defaults vararg kwarg body Assign NameStore Call NameLoad For TupleStore NameStore NameStore NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Assign SubscriptStore AttributeLoad NameLoad attr Index NameLoad NameLoad TryFinally body Return Call NameLoad NameLoad NameLoad finalbody Expr Call AttributeLoad NameLoad attr decorator_list Return NameLoad decorator_list FunctionDef arguments args NameParam defaults vararg body Expr Str FunctionDef arguments args defaults vararg kwarg body Assign NameStore Call NameLoad NameLoad For NameStore NameLoad body Assign SubscriptStore AttributeLoad NameLoad attr Index NameLoad Call NameLoad NameLoad TryFinally body Return Call NameLoad NameLoad NameLoad finalbody Expr Call AttributeLoad NameLoad attr decorator_list Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore BinOpAdd Str NameLoad If CompareIn NameLoad AttributeLoad NameLoad attr body Return Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Assign NameStore Call NameLoad TupleLoad NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad Assign NameStore Dict Str Str Str Str If CompareIn NameLoad NameLoad body Assign NameStore SubscriptLoad NameLoad Index NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Assign SubscriptStore AttributeLoad NameLoad attr Index NameLoad Call NameLoad NameLoad TryFinally body Assign NameStore Call NameLoad NameLoad Dict Dict SubscriptLoad Call AttributeLoad NameLoad attr Str Slice Num Assign SubscriptStore AttributeLoad NameLoad attr Index NameLoad NameLoad finalbody Expr Call AttributeLoad NameLoad attr Return SubscriptLoad AttributeLoad NameLoad attr Index NameLoad decorator_list Assign NameStore Dict FunctionDef arguments args defaults kwarg body Expr Str Expr Call AttributeLoad NameLoad attr Str Assign NameStore Set Str Str Str Str Str Str Str Str Assign NameStore Call AttributeLoad NameLoad attr Str NameLoad For NameStore Call AttributeLoad NameLoad attr body If CompareNotIn NameLoad NameLoad body Raise Call NameLoad BinOpMod Str NameLoad If CompareIs NameLoad NameLoad body Assign NameStore UnaryOpNot CompareIn NameLoad Call AttributeLoad NameLoad attr For NameStore NameLoad body If CompareEq NameLoad Str body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore ListLoad If BoolOpAnd SubscriptLoad NameLoad Index Str UnaryOpNot Call AttributeLoad NameLoad attr Str body AugAssignAdd NameStore Call NameLoad Assign SubscriptStore NameLoad Index Str NameLoad If BoolOpAnd SubscriptLoad NameLoad Index Str UnaryOpNot Call AttributeLoad NameLoad attr Str body AugAssignAdd NameStore Call NameLoad Assign SubscriptStore NameLoad Index Str NameLoad If BoolOpAnd SubscriptLoad NameLoad Index Str UnaryOpNot Call AttributeLoad NameLoad attr Str body AugAssignAdd NameStore Call NameLoad Assign SubscriptStore NameLoad Index Str NameLoad If BoolOpAnd SubscriptLoad NameLoad Index Str UnaryOpNot Call AttributeLoad NameLoad attr Str body AugAssignAdd NameStore Call NameLoad Assign SubscriptStore NameLoad Index Str NameLoad If BoolOpAnd SubscriptLoad NameLoad Index Str UnaryOpNot Call AttributeLoad NameLoad attr Str body AugAssignAdd NameStore Call NameLoad Assign SubscriptStore NameLoad Index Str NameLoad If BoolOpAnd Call AttributeLoad NameLoad attr Str UnaryOpNot Call AttributeLoad NameLoad attr Str body AugAssignAdd NameStore Call NameLoad Assign SubscriptStore NameLoad Index Str NameLoad If BoolOpAnd SubscriptLoad NameLoad Index Str UnaryOpNot Call AttributeLoad NameLoad attr Str body TryExcept body ImportFrom alias Expr Call AttributeLoad NameLoad attr Assign SubscriptStore NameLoad Index Str NameLoad handlers ExceptHandler type NameLoad body Pass Expr Call AttributeLoad NameLoad attr TryFinally body For TupleStore NameStore NameStore NameLoad body Expr Call AttributeLoad NameLoad attr Call AttributeLoad Str attr NameLoad NameLoad Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad If CompareIs NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad For NameStore AttributeLoad NameLoad attr body Assign NameStore Call NameLoad NameLoad NameLoad NameLoad If CompareIsNot NameLoad NameLoad body Expr Call NameLoad NameLoad NameLoad NameLoad finalbody Expr Call AttributeLoad NameLoad attr If BoolOpAnd SubscriptLoad NameLoad Index Str UnaryOpNot Call AttributeLoad NameLoad attr Str body TryExcept body Import alias ImportFrom alias Assign AttributeStore AttributeLoad NameLoad attr attr NameLoad Assign AttributeStore AttributeLoad AttributeLoad NameLoad attr attr attr NameLoad Assign SubscriptStore NameLoad Index Str NameLoad handlers ExceptHandler type NameLoad body Pass decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return BoolOpOr CompareIn NameLoad NameLoad CompareIn Call NameLoad NameLoad Str NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults ListLoad NameLoad body Expr Str If CompareIs NameLoad NameLoad body Assign NameStore AttributeLoad NameLoad attr Assign NameStore DictComp NameLoad Call NameLoad NameLoad NameLoad comprehension NameStore NameLoad UnaryOpNot BoolOpOr Call AttributeLoad NameLoad attr Str CompareIn NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args defaults body ImportFrom alias Return ListLoad TupleLoad Str NameLoad decorator_list FunctionDef arguments args defaults body ImportFrom alias Return ListLoad TupleLoad Str NameLoad decorator_list FunctionDef arguments args defaults body ImportFrom alias TryExcept body ImportFrom alias Return ListLoad TupleLoad Str NameLoad TupleLoad Str NameLoad handlers ExceptHandler type NameLoad body Return ListLoad TupleLoad Str NameLoad decorator_list FunctionDef arguments args defaults body ImportFrom alias alias alias Return ListLoad TupleLoad Str NameLoad TupleLoad Str NameLoad TupleLoad Str NameLoad decorator_list FunctionDef arguments args defaults body ImportFrom alias Return ListLoad TupleLoad Str NameLoad decorator_list FunctionDef arguments args defaults body TryExcept body ImportFrom alias Return ListLoad TupleLoad Str NameLoad handlers ExceptHandler type NameLoad body Return ListLoad decorator_list
N/A N/A imp N/A sys N/A logging N/A importlib N/A __all__ N/A monkey_patch original is_monkey_patched inject import_patched patch_function N/A __exclude N/A __builtins__ __file__ __name__ N/A log N/A N/A logging getLogger guv SysModulesSaver N/A N/A N/A Class that captures some subset of the current state of sys.modules
     __init__ N/A N/A self module_names N/A N/A N/A N/A 
        :param module_names: iterator of module names
         N/A N/A self _saved N/A N/A N/A N/A imp acquire_lock N/A N/A N/A self save module_names N/A save N/A N/A self N/A module_names N/A N/A Saves the named modules to the object. N/A modname module_names N/A N/A N/A N/A self _saved N/A modname N/A N/A N/A sys modules get modname None N/A restore N/A N/A self N/A N/A N/A Restores the modules that the saver knows about into
        sys.modules.
         N/A N/A N/A N/A modname mod N/A N/A N/A self _saved items N/A N/A N/A mod None N/A N/A N/A N/A sys modules N/A modname mod N/A N/A N/A N/A N/A N/A sys modules N/A modname N/A N/A N/A KeyError N/A N/A N/A N/A N/A N/A imp release_lock N/A N/A inject N/A N/A module_name new_globals N/A additional_modules N/A N/A Inject greenified modules into an imported module

    This method imports the module specified in `module_name`, arranging things so that the
    already-imported modules in `additional_modules` are used when `module_name` makes its imports.

    `new_globals` is either None or a globals dictionary that gets populated with the contents of
    the `module_name` module. This is useful when creating a "green" version of some other module.

    `additional_modules` should be a collection of two-element tuples, of the form
    ``(name: str,  module: str)``. If it's not specified, a default selection of name/module pairs
    is used, which should cover all use cases but may be slower because there are inevitably
    redundant or unnecessary imports.
     N/A patched_name N/A __patched_module_ module_name N/A N/A patched_name N/A sys modules N/A N/A N/A N/A sys modules N/A patched_name N/A N/A additional_modules N/A N/A additional_modules N/A N/A N/A N/A N/A _green_os_modules N/A _green_select_modules N/A _green_socket_modules N/A _green_thread_modules N/A _green_time_modules N/A saver N/A SysModulesSaver N/A name N/A N/A name m additional_modules N/A N/A N/A saver save module_name N/A N/A name mod additional_modules N/A N/A N/A N/A sys modules N/A name mod N/A N/A N/A N/A sys modules pop module_name None N/A N/A N/A module N/A __import__ module_name N/A N/A N/A N/A N/A module_name split . N/A -1 N/A N/A new_globals None N/A N/A name N/A dir module N/A N/A N/A name __exclude N/A N/A N/A new_globals N/A name N/A getattr module name N/A N/A N/A sys modules N/A patched_name module N/A N/A N/A N/A saver restore N/A module N/A import_patched N/A N/A module_name N/A additional_modules kw_additional_modules N/A N/A Import patched version of module

    :param str module_name: name of module to import
     N/A N/A inject module_name None N/A additional_modules N/A tuple N/A N/A kw_additional_modules items N/A patch_function N/A N/A func N/A additional_modules N/A N/A Decorator that returns a version of the function that patches some modules for the
    duration of the function call

    This should only be used for functions that import network libraries within their function
    bodies that there is no way of getting around.
     N/A N/A additional_modules N/A N/A additional_modules N/A N/A N/A N/A N/A _green_os_modules N/A _green_select_modules N/A _green_socket_modules N/A _green_thread_modules N/A _green_time_modules patched N/A N/A N/A args kw N/A N/A saver N/A SysModulesSaver N/A N/A name mod additional_modules N/A N/A N/A N/A saver save name N/A N/A N/A sys modules N/A name mod N/A N/A N/A N/A func args kw N/A N/A N/A N/A saver restore N/A N/A patched N/A _original_patch_function N/A N/A func N/A module_names N/A N/A Opposite of :func:`patch_function`

    Decorates a function such that when it's called, sys.modules is populated only with the
    unpatched versions of the specified modules. Unlike patch_function, only the names of the
    modules need be supplied, and there are no defaults.
     patched N/A N/A N/A args kw N/A N/A saver N/A SysModulesSaver module_names N/A name module_names N/A N/A N/A N/A sys modules N/A name N/A original name N/A N/A N/A N/A func args kw N/A N/A N/A N/A saver restore N/A N/A patched N/A original N/A N/A modname N/A N/A N/A Return an unpatched version of a module

    This is useful for guv itself.

    :param str modname: name of module
     N/A original_name N/A __original_module_ modname N/A N/A original_name N/A sys modules N/A N/A N/A N/A N/A sys modules get original_name N/A saver N/A SysModulesSaver N/A modname N/A N/A N/A N/A sys modules pop modname None N/A deps N/A threading queue _thread threading N/A N/A modname deps N/A N/A dependency N/A deps N/A modname N/A N/A N/A saver save dependency N/A N/A N/A sys modules N/A dependency N/A original dependency N/A N/A N/A real_mod N/A __import__ modname N/A N/A N/A N/A N/A modname split . N/A -1 N/A N/A N/A sys modules N/A original_name real_mod N/A N/A N/A N/A saver restore N/A N/A N/A sys modules N/A original_name N/A N/A already_patched N/A monkey_patch N/A N/A N/A modules N/A N/A Globally patch/configure system modules to to be greenlet-friendly

    If no keyword arguments are specified, all possible modules are patched. If keyword arguments
    are specified, the specified modules (and their dependencies) will be patched.

    - Patching :mod:`socket` will also patch :mod:`ssl`
    - Patching :mod:`threading` will also patch :mod:`_thread` and :mod:`queue`

    It's safe to call monkey_patch multiple times.

    Example::

        monkey_patch(time=True, socket=True, select=True)

    :keyword bool time: time module: patches sleep()
    :keyword bool os: os module: patches open(), read(), write(), wait(), waitpid()
    :keyword bool socket: socket module: patches socket, create_connection()
    :keyword bool select: select module: patches select()
    :keyword bool threading: threading module: patches local, Lock(), stack_size(), current_thread()
    :keyword bool psycopg2: psycopg2 module: register a wait callback to yield
    :keyword bool cassandra: cassandra module: set connection class to GuvConnection
     N/A N/A N/A log debug Begin monkey-patching N/A accepted_args N/A os select socket threading time psycopg2 cassandra __builtin__ N/A default_modules N/A N/A modules pop all None N/A k N/A N/A modules keys N/A N/A N/A k accepted_args N/A N/A N/A TypeError N/A monkey_patch() got an unexpected keyword argument %r k N/A N/A default_modules None N/A N/A default_modules N/A N/A True N/A N/A modules values N/A modname accepted_args N/A N/A N/A modname __builtin__ N/A N/A N/A N/A modules setdefault modname False N/A N/A N/A modules setdefault modname default_modules N/A modules_to_patch N/A N/A N/A N/A modules N/A os N/A N/A N/A already_patched get os N/A N/A modules_to_patch N/A _green_os_modules N/A N/A already_patched N/A os True N/A N/A N/A modules N/A select N/A N/A N/A already_patched get select N/A N/A modules_to_patch N/A _green_select_modules N/A N/A already_patched N/A select True N/A N/A N/A modules N/A socket N/A N/A N/A already_patched get socket N/A N/A modules_to_patch N/A _green_socket_modules N/A N/A already_patched N/A socket True N/A N/A N/A modules N/A threading N/A N/A N/A already_patched get threading N/A N/A modules_to_patch N/A _green_thread_modules N/A N/A already_patched N/A threading True N/A N/A N/A modules N/A time N/A N/A N/A already_patched get time N/A N/A modules_to_patch N/A _green_time_modules N/A N/A already_patched N/A time True N/A N/A N/A N/A modules get __builtin__ N/A N/A N/A already_patched get __builtin__ N/A N/A modules_to_patch N/A _green_builtins N/A N/A already_patched N/A __builtin__ True N/A N/A N/A modules N/A psycopg2 N/A N/A N/A already_patched get psycopg2 N/A N/A N/A guv.support psycopg2_patcher N/A N/A N/A psycopg2_patcher make_psycopg_green N/A N/A already_patched N/A psycopg2 True N/A N/A N/A ImportError N/A N/A N/A N/A N/A imp acquire_lock N/A N/A N/A N/A name mod modules_to_patch N/A N/A N/A N/A log debug N/A N/A patch: {:20} -> {} format name mod N/A orig_mod N/A N/A N/A sys modules get name N/A N/A orig_mod None N/A N/A orig_mod N/A N/A importlib import_module name N/A attr_name N/A mod __patched__ N/A N/A patched_attr N/A getattr mod attr_name None N/A N/A patched_attr None N/A N/A N/A setattr orig_mod attr_name patched_attr N/A N/A N/A N/A imp release_lock N/A N/A N/A modules N/A cassandra N/A N/A N/A already_patched get cassandra N/A N/A N/A N/A cassandra.cluster guv.support.cassandra GuvConnection N/A N/A N/A cassandra cluster DefaultConnection GuvConnection N/A N/A N/A N/A cassandra cluster Cluster connection_class GuvConnection N/A N/A already_patched N/A cassandra True N/A N/A N/A ImportError N/A N/A N/A is_monkey_patched N/A N/A module N/A N/A N/A Check if the specified module is currently patched

    Based entirely off the name of the module, so if you import a module some other way than with
    the import keyword (including import_patched), this might not be correct about that particular
    module

    :param module: module to check (moduble object itself, or its name str)
    :type module: module or str
    :return: True if the module is patched else False
    :rtype: bool
     N/A N/A N/A module already_patched N/A N/A getattr module __name__ None already_patched N/A copy_attributes N/A N/A source destination ignore srckeys N/A N/A None N/A N/A Copy properties from `source` to `destination`

    :param module source: source module
    :param dict destination: destination dict
    :param list ignore: list of properties that should not be copied
    :param list srckeys: list of keys to copy, if the source's __all__ is untrustworthy
     N/A N/A srckeys None N/A N/A srckeys N/A source __all__ N/A d N/A name N/A getattr source name N/A name srckeys N/A N/A N/A N/A name startswith __ N/A name ignore N/A N/A N/A destination update d N/A _green_os_modules N/A N/A N/A N/A guv.green os N/A N/A N/A os os N/A _green_select_modules N/A N/A N/A N/A guv.green select N/A N/A N/A select select N/A _green_socket_modules N/A N/A N/A N/A guv.green socket N/A N/A guv.green ssl N/A N/A N/A socket socket N/A ssl ssl N/A N/A N/A ImportError N/A N/A N/A N/A socket socket N/A _green_thread_modules N/A N/A N/A N/A guv.green queue thread threading N/A N/A N/A queue queue N/A _thread thread N/A threading threading N/A _green_time_modules N/A N/A N/A N/A guv.green time N/A N/A N/A time time N/A _green_builtins N/A N/A N/A N/A N/A N/A guv.green builtin N/A N/A N/A __builtin__ builtin N/A N/A N/A ImportError N/A N/A N/A N/A