celery_mandelbrot.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:Software-Architecture-with-Python 作者: PacktPublishing 项目源码 文件源码
def mandelbrot_main(w, h, max_iterations=1000, output='mandelbrot_celery.png'):
    """ Main function for mandelbrot program with celery """

    job = group([mandelbrot_calc_row.s(y, w, h, max_iterations) for y in range(h)])
    result = job.apply_async()

    image = Image.new('RGB', (w, h))

    for image_rows in result.join():
        for k,v in image_rows.items():
            k = int(k)
            v = tuple(map(int, v))
            x,y = k % args.width, k // args.width
            image.putpixel((x,y), v)

    image.save(output, 'PNG')
    print('Saved to',output)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号