推荐学习书目
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
simple2025
0D
V2EX  ›  Python

Python _multiprocess 模块里面有个叫 SemLock 的东西是什么?

  •  
  •   simple2025 · Jun 24, 2017 · 4065 views
    This topic created in 3332 days ago, the information mentioned may be changed or developed.

    在 python 官方文档里面也没有找到 SemLock 的说明,但是
    在 celery 代码里面又看到 SemLock 在被使用,有人知道是怎么回事吗?

    Supplement 1  ·  Jun 24, 2017
    能给个相关文档给我吗
    python 版那是最好不过了
    6 replies    2017-06-25 01:10:58 +08:00
    zjsxwc
        1
    zjsxwc  
       Jun 24, 2017   ❤️ 1
    看名字就知道是信号量锁呀
    simple2025
        2
    simple2025  
    OP
       Jun 24, 2017
    @zjsxwc 有没有例子说明下呀
    noli
        3
    noli  
       Jun 24, 2017 via iPhone
    @chenqh 信号量没听过的话应该去查操作系统原理。
    simple2025
        4
    simple2025  
    OP
       Jun 24, 2017
    @noli 信号量不是 semaphore 这个吗 Semlock 难道等于 semaphore?
    zoues
        5
    zoues  
       Jun 24, 2017 via iPhone
    这么问不如翻番代码
    NoAnyLove
        6
    NoAnyLove  
       Jun 25, 2017   ❤️ 1
    multiprocessing 中的 SemLock 是用来构建 Semaphore 和 Mutex 的基类。见 Python27\Lib\multiprocessing\synchronize.py

    _multiprocessing 中的 SemLock 是对应的底层实现,根据不同的系统,调用不同的系统 API。比如 Windows 下用 CreateSemaphore,Linux/Unix 下用 sem_open,用于创建系统信号量。见 Python 源码\Modules\_multiprocessing\semaphore.c

    说真的,你有这闲工夫发帖子,不如自己翻一下代码就什么都懂了。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2717 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 12:44 · PVG 20:44 · LAX 05:44 · JFK 08:44
    ♥ Do have faith in what you're doing.