def _get_async_wrapper(self):
def async_wrapper(*args, **kwargs):
# TODO handle this better in the future, but stop the massive error
# caused by MacOSX async runs for now.
try:
import matplotlib as plt
if plt.rcParams['backend'].lower() == 'macosx':
raise EnvironmentError(backend_error_template %
plt.matplotlib_fname())
except ImportError:
pass
# This function's signature is rewritten below using
# `decorator.decorator`. When the signature is rewritten, args[0]
# is the function whose signature was used to rewrite this
# function's signature.
args = args[1:]
pool = concurrent.futures.ProcessPoolExecutor(max_workers=1)
future = pool.submit(_subprocess_apply, self, args, kwargs)
pool.shutdown(wait=False)
return future
async_wrapper = self._rewrite_wrapper_signature(async_wrapper)
self._set_wrapper_properties(async_wrapper)
self._set_wrapper_name(async_wrapper, 'async')
return async_wrapper
评论列表
文章目录