推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
chuncey
V2EX  ›  Python

Python 如何在类内多进程执行此类内的方法

  •  
  •   chuncey · Apr 17, 2018 · 6397 views
    This topic created in 3130 days ago, the information mentioned may be changed or developed.

    有一个类似这样的类

    class Foo:
    
     def __init__(self):
        self.x = ''
        
     def func_1(self):
        self.x += 'f1'
        
     def func_2(self):
        self.x += 'f2'
        
     def process(self):
        self.func_1()
        self.func_2()
    

    有办法让类内的 func_1 和 func_2 同时执行吗(func_1 和 func_2 实例为爬虫程序)?

    7 replies  •  2018-04-18 10:06:36 +08:00
    orderc
    orderc
    Apr 17, 2018❤️1
    1
    读这个标题舌头快打结了。。
    orangeade
    orangeade
    Apr 17, 2018 via Android❤️1
    3
    concurrent.futures.ProcessPoolExecutor
    或者 Asyncio ?
    di94sh
    di94sh
    Apr 18, 2018❤️1
    4
    di94sh
    di94sh
    Apr 18, 2018
    5
    使用多进程, 要改写父进程资源, 要使用一些进程间的通信手段, 共享内存在这里就挺合适的..不过要注意,多进程的同步,
    就是使用信号量,
    ZoomQuiet
    ZoomQuiet
    Apr 18, 2018 via iPhone
    6
    redis
    shuizhengqi
    shuizhengqi
    Apr 18, 2018
    7
    使用 celery 了解一下?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2303 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 13:09 · PVG 21:09 · LAX 05:09 · JFK 08:09
    ♥ Do have faith in what you're doing.