def background(func):
"""
Will run you function in the background.
Please note that there are probably ways to abuse this to run code in the parent.
In the future, we need to get a serilization method that isn't "pickle" running, for security.
It returns a "Service" object, which right now is pretty much identical to a multiprocess.Process object
TODO: Replace the built in pickle? serialization with something else. Maybe rpyc's brine.
http://stackoverflow.com/a/13019405
https://docs.python.org/2/library/multiprocessing.html#connection-objects
"""
def func_wrapper(*args,**kwargs):
p = Service(target = func, args=args, kwargs=kwargs, daemon = False)
return p
return func_wrapper
评论列表
文章目录