Argument "q" of both targets is the same and is given by main process. ######################################## # IN LOADER PROCESS ######################################## ... import builtins ... def get_descriptor(f): c = f.__code__ globals_ = { } builtins_ = [] for name in c.co_names : if not name in dir(builtins): globals_[name] = f.__globals__[name] else: builtins_.append(name) return (c.co_argcount, c.co_kwonlyargcount, c.co_nlocals, c.co_stacksize, c.co_flags, c.co_code, c.co_consts, c.co_names, c.co_varnames, c.co_filename, c.co_name, c.co_firstlineno, c.co_lnotab), globals_, builtins_ def _loader(..., q, ...): # this is loader/writer target ... # kind is instance of type # plugin is loaded by YAPSY, it is instance of PluginInfo # meta is dict with strings as both keys and values print("Putting tuple", (kind, plugin, meta), "in serialized form") # line 87 of loader_process.py def x(): print("doing x") val = (kind, plugin, meta) print("val", val) return val q.put( get_descriptor(x) ) ... ######################################## # IN CONSUMER PROCESS ######################################## ... import builtins from types import CodeType, FunctionType ... def get_function(desc): globals_ = {} for k, v in desc[1].items(): globals_[k]=v for k in desc[2]: globals_[k]=getattr(builtins, k) return FunctionType(CodeType(*desc[0]), globals_) def _consumer(..., q, ...): #this is consumer target ... from_queue = q.get() foo = get_function(from_queue) # line 25 of consumer_stub.py print("foo", foo) result = foo() print("result", result) kind, p, meta = result print("At", datetime.utcnow(), "plugin (", kind, ")", p, '''was loaded this is its metadata:''', meta)