Linux OSError 38 [Errno 38] 多处理

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6033599/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 04:07:38  来源:igfitidea点击:

OSError 38 [Errno 38] with multiprocessing

pythonlinuxmultiprocessing

提问by xyz-123

I'm having the following error:

我有以下错误:

$ sudo chmod a+rwxt /dev/shm/
$ ls -ld /dev/shm/
drwxrwxrwt 2 root root 4096 Feb  4 06:56 /dev/shm/
$ python
Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import multiprocessing
>>> mp = multiprocessing.Pool(2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/multiprocessing/__init__.py", line 227, in Pool
    return Pool(processes, initializer, initargs)
  File "/usr/lib/python2.6/multiprocessing/pool.py", line 84, in __init__
    self._setup_queues()
  File "/usr/lib/python2.6/multiprocessing/pool.py", line 131, in _setup_queues
    self._inqueue = SimpleQueue()
  File "/usr/lib/python2.6/multiprocessing/queues.py", line 328, in __init__
    self._rlock = Lock()
  File "/usr/lib/python2.6/multiprocessing/synchronize.py", line 117, in __init__
    SemLock.__init__(self, SEMAPHORE, 1, 1)
  File "/usr/lib/python2.6/multiprocessing/synchronize.py", line 49, in __init__
    sl = self._semlock = _multiprocessing.SemLock(kind, value, maxvalue)
OSError: [Errno 38] Function not implemented

What else could be the reason for this error (apart from read/write access to /dev/shm)?

此错误的其他原因可能是什么(除了对 /dev/shm 的读/写访问)?

Thanks!

谢谢!

回答by Boaz Yaniv

I suspect this have to do something with this: http://bugs.python.org/issue3770

我怀疑这与此有关:http: //bugs.python.org/issue3770

From the Python docs:

来自 Python 文档:

Warning: Some of this package's functionality requires a functioning shared semaphore implementation on the host operating system. Without one, the multiprocessing.synchronizemodule will be disabled, and attempts to import it will result in an ImportError. See issue 3770 for additional information.

This may or may not be related, since it talks about multiprocessing.synchronize, but from what I understand, some implementations on some platforms just don't implement the semaphore API python relies upon here, which might be your problem.

这可能相关,也可能不相关,因为它谈论的是multiprocessing.synchronize,但据我所知,某些平台上的某些实现只是没有实现 python 依赖的信号量 API 在这里,这可能是您的问题。

回答by Christian B

For anyone else coming here from Google, the answer is at Django Celery Implementation - OSError errno 38 - Function not implemented:

对于从 Google 来到这里的其他人,答案在Django Celery Implementation - OSError errno 38 - Function not implements 中

Got it working by adding none /dev/shm tmpfs rw,nosuid,nodev,noexec 0 0to /etc/fstaband rebooting

得到它的工作,加入none /dev/shm tmpfs rw,nosuid,nodev,noexec 0 0/etc/fstab和重新启动

Instead of rebooting, sudo mount /dev/shmworks.

而不是重新启动,sudo mount /dev/shm工作。