Home  >  Q&A  >  body text

使用python multithreading.Pool 做多线程,遭遇bug3770,如何解?

使用python multithreading.Pool 做多线程,遭遇bug3770,如何解?

Python版本:2.7.3
系统版本:centos release 4.3
出错语句:pool = Pool(4)
错误信息:ImportError: This platform lacks a functioning sem_open implementation, therefore, the required synchronization primitives needed will not function, see issue 3770

简单来说是python不支持操作系统中关于共享信号量的设置。看了些别人的帖子,也看了python官网对这个bug的解释,但是都解决不了现在的问题。
操作系统改不了,有什么方法能绕过这个问题呀,求明白人支招~~~

伊谢尔伦伊谢尔伦2742 days ago1150

reply all(2)I'll reply

  • 黄舟

    黄舟2017-04-17 14:29:09

    Are you going to do multi-threading or multi-processing? I remember that the pool seems to be multi-process

    reply
    0
  • 迷茫

    迷茫2017-04-17 14:29:09

    Attached is the standard answer:
    Cause: /dev/shm is not mounted; something needs to be written during python installation to enable sem_open
    Solution: (root permission is required; the following command is executed with the root account)

    1. Modify /etc/fstab and add: tmpfs /dev/shm tmpfs defaults 0 0

    2. mount /dev/shm

    3. chmod 777 /dev/shm

    4. Reinstall python (must reinstall, there is no way, check whether the device exists during installation, if it exists, you can use sem_open)

    reply
    0
  • Cancelreply