Python Multiprocessing: Denial of Rights

I get an error when trying to execute a python program that uses a multiprocessing package:

File "/usr/local/lib/python2.6/multiprocessing/__init__.py", line 178, in RLock return RLock() File "/usr/local/lib/python2.6/multiprocessing/synchronize.py", line 142, in __init__ SemLock.__init__(self, RECURSIVE_MUTEX, 1, 1) File "/usr/local/lib/python2.6/multiprocessing/synchronize.py", line 49, in __init__ sl = self._semlock = _multiprocessing.SemLock(kind, value, maxvalue) OSError: [Errno 13] Permission denied 

It appears that the user does not have permission to access shared memory. When run with root privileges, it works fine.

Is there any solution to run it as a regular user (not root)?

Python version 2.6.2, OS Linux 2.6.18 (CentOS 5.4 version) and VPS machine.

+49
python linux
Jan 05 '10 at 21:37
source share
3 answers

For POSIX semaphores to work, users need r / w access to shared memory ( /dev/shm ).

Check permissions on /dev/shm . On my laptop (Ubuntu), it looks like this:

 $ ls -ld /dev/shm drwxrwxrwt 2 root root 40 2010-01-05 20:34 shm 

To permanently set the correct permissions (even after rebooting), add the following to your /etc/fstab :

 none /dev/shm tmpfs rw,nosuid,nodev,noexec 0 0 

Did not try this, just copied from the message.

+65
Jan 05 '10 at 22:15
source share

In my OVH VPS Classic, this error was caused by a loop in / dev / shm and / run / shm. Both were symbolic links linked together. So, as root, here is what I did:

 # rm /dev/shm # mkdir /dev/shm # chmod 777 /dev/shm # nano /etc/fstab 

Then I changed the shm line:

 none /dev/shm tmpfs rw 0 0 

To:

 none /dev/shm tmpfs rw,nosuid,nodev,noexec 0 0 

Rebooted the server ... And this fixed the problem! Alternatively, you can install shm manually:

 # mount /dev/shm 

Hope this helps :-)

+3
Nov 06 '14 at 10:14
source share

One simple solution without rebooting

 sudo chmod 777 /dev/shm 

This solved my problem.

0
Dec 12 '18 at 11:33
source share



All Articles