V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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
chu8129
V2EX  ›  Python

python 中的三种 Queue 有什么区别??

  •  
  •   chu8129 ·
    chu8129 · 2016-04-09 11:28:58 +08:00 · 6071 次点击
    这是一个创建于 2943 天前的主题,其中的信息可能已经有所发展或是发生改变。

    python 中有三种 Queue ;但不是很清楚三个之间的区别;希望了解的大神解释一下:


    import Queue
    myqueue = Queue.Queue()

    from multiprocessing import Queue
    myqueue = Queue.Queue()

    import multiprocessing
    manager=multiprocessing.Manager()
    myqueue=manager.Queue()
    3 条回复    2016-04-09 20:42:18 +08:00
    icedx
        1
    icedx  
       2016-04-09 11:37:15 +08:00   ❤️ 1
    Queue.Queue 是进程内非阻塞队列
    multiprocess.Queue 是跨进程通信队列
    前者是各自进程私有, 后者是各子进程共有
    chu8129
        2
    chu8129  
    OP
       2016-04-09 14:26:19 +08:00
    @icedx 非常感谢;那 manager 那个呢?
    icedx
        3
    icedx  
       2016-04-09 20:42:18 +08:00
    @chu8129 .Manager 是 multiprocessing 的封装 .Manager.Queue 和 Queue, multiprocessing.Queue 没有太大关系
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2591 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 14:48 · PVG 22:48 · LAX 07:48 · JFK 10:48
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.