使用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的解释,但是都解决不了现在的问题。
操作系统改不了,有什么方法能绕过这个问题呀,求明白人支招~~~
Are you going to do multi-threading or multi-processing? I remember that the pool seems to be multi-process
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)
Modify /etc/fstab and add: tmpfs /dev/shm tmpfs defaults 0 0
mount /dev/shm
chmod 777 /dev/shm
Reinstall python (must reinstall, there is no way, check whether the device exists during installation, if it exists, you can use sem_open)