Python非root用户启动python multiprocessing的semlock,提示没有权限的解决方法

使用进程间通信的时候
Python报错为
<span style="font-size:18px;">Traceback (most recent call last):
  File "web_game_sign.py", line 483, in <module>
    count = multiprocessing.Value('i', 1)
  File "/usr/lib64/python2.6/multiprocessing/__init__.py", line 248, in Value
    return Value(typecode_or_type, *args, **kwds)
  File "/usr/lib64/python2.6/multiprocessing/sharedctypes.py", line 75, in Value
    lock = RLock()
  File "/usr/lib64/python2.6/multiprocessing/__init__.py", line 178, in RLock
    return RLock()
  File "/usr/lib64/python2.6/multiprocessing/synchronize.py", line 142, in __init__
    SemLock.__init__(self, RECURSIVE_MUTEX, 1, 1)
  File "/usr/lib64/python2.6/multiprocessing/synchronize.py", line 49, in __init__
    sl = self._semlock = _multiprocessing.SemLock(kind, value, maxvalue)
OSError: [Errno 13] Permission denied</span>



原因是因为用户没有shared memory(/dev/shm)的读写权限,需要将/dev/shm的权限改成:
drwxrwxrwx  2 root root 80 Mar 25 11:39 /dev/shm

你可能感兴趣的:(Python非root用户启动python multiprocessing的semlock,提示没有权限的解决方法)