16

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)?

Thanks!

xyz-123
  • 2,227
  • 4
  • 21
  • 27
  • did you compile this python from source? – tMC May 17 '11 at 15:57
  • Did you check this related question: http://stackoverflow.com/questions/3314031/django-celery-implementation-oserror-errno-38-function-not-implemented – Mu Mind May 17 '11 at 16:19
  • it seems that this is a debian amd64 and ppc specific bug... – xyz-123 May 17 '11 at 16:54
  • @Bobby this is not what you think. Read http://stackoverflow.com/questions/3314031/django-celery-implementation-oserror-errno-38-function-not-implemented – Matt Williamson Jan 26 '12 at 23:16
  • @xyz-123 Not really, I'm experiencing it on an arm9 system: http://stackoverflow.com/questions/21069668/enumarate-through-dictionary-with-python-2-6/21069676?noredirect=1#21069676 – stdcerr Jan 12 '14 at 01:01

2 Answers2

20

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

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

Instead of rebooting, sudo mount /dev/shm works.

Community
  • 1
  • 1
Christian B
  • 581
  • 4
  • 7
7

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

From the Python docs:

Warning: Some of this package’s functionality requires a functioning shared semaphore implementation on the host operating system. Without one, the multiprocessing.synchronize module 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.

Boaz Yaniv
  • 6,334
  • 21
  • 30
  • but this would lead to an ImportError rather than the OSError? – xyz-123 May 17 '11 at 16:43
  • it may not be an import error as there are other pieces of the module which may be of use – tMC May 17 '11 at 17:24
  • @ahojnnes: I'm not quite sure. Looking at the C source code, there are several places from which an OSError may be thrown. Whether or not they're thrown, but they seem to be based on the OS error value (e.g. errno or GetLastError()). – Boaz Yaniv May 17 '11 at 19:04