本文整理汇总了Python中multiprocessing.pool.Pool._wrap_exception方法的典型用法代码示例。如果您正苦于以下问题:Python Pool._wrap_exception方法的具体用法?Python Pool._wrap_exception怎么用?Python Pool._wrap_exception使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类multiprocessing.pool.Pool
的用法示例。
在下文中一共展示了Pool._wrap_exception方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render
# 需要导入模块: from multiprocessing.pool import Pool [as 别名]
# 或者: from multiprocessing.pool.Pool import _wrap_exception [as 别名]
def render(self, scene, bucket_order_info: BucketOrderInfo, multiThread: bool=True):
self.scene = scene
if self.surface_integrator is not None:
self.surface_integrator.Preprocess(scene, self.camera, self)
if self.volume_integrator is not None:
self.volume_integrator.Preprocess(scene, self.camera, self)
sample = Sample(self.main_sampler, self.surface_integrator, self.volume_integrator, scene)
if multiThread:
my_bucket_orders = BucketOrder.create(bucket_order_info.width, bucket_order_info.height,
bucket_order_info.bucket_order_type)
pool = Pool(processes=multiprocessing.cpu_count())
# pool = Pool(processes=1)
pool._wrap_exception = False
results = []
for i in range(bucket_order_info.width * bucket_order_info.height):
# for i in range(55, 56):
a = pool.apply_async(self.render_task, args=(
i, my_bucket_orders.buckets_orders[i], bucket_order_info, sample, self),
callback=self.draw)
results.append(a)
for r in results:
r.wait()
else:
bucketOrderInfo = BucketOrderInfo(BucketOrderSortType.Random, 1, 1)
self.render_task(0, 0, bucketOrderInfo, sample, self)
print("Render end")
data = write_png(self.camera.film.data, self.camera.film.width, self.camera.film.height)
with open("my_image.png", 'wb') as fd:
fd.write(data)