from multiprocessing import Pool
def with_app_context(need_new=False):
def magic(func):
app_store = {}
def wrapper(*args, **kwargs):
print 'inside', args, kwargs
result = func(*args, **kwargs)
return result
return wrapper
return magic
@with_app_context(need_new=True)
def func(k1, k2):
print k1, k2
return 'ret'
pool = Pool(processes=1)
pool.apply_async(func, args=('hi', 'yo'))
pool.close()
pool.join()
什么结果都不输出, 请问哪有bug?
It seems that for this reason, function decorators cannot be pickled
You can take a look at this:
Decorators and multi-processes and Pickle
Extension: Python MultiProcessing usage experience
I have found the reason:
Exception in child process.
http://stackoverflow.com/ques...