Skip to main content
 首页 » 编程设计

python之创建信号量时“设备上没有剩余空间”

2024年10月25日10bluestorm

我最近开始在 Macbook Pro (OS X 10.10) 上使用 Python 观察到以下错误。根据磁盘实用程序,120 GB SSD 驱动器的大约一半仍然可用,所以我怀疑这与磁盘无关,而是与其他文件系统属性有关?

哪些因素控制信号量的可用空间量?我该怎么做才能解决这个问题?

$ python -c 'import multiprocessing; multiprocessing.Semaphore()' 
Traceback (most recent call last): 
  File "<string>", line 1, in <module> 
  File "/Users/rmcgibbo/miniconda/envs/3.4.2/lib/python3.4/multiprocessing/context.py", line 81, in Semaphore 
    return Semaphore(value, ctx=self.get_context()) 
  File "/Users/rmcgibbo/miniconda/envs/3.4.2/lib/python3.4/multiprocessing/synchronize.py", line 127, in __init__ 
    SemLock.__init__(self, SEMAPHORE, value, SEM_VALUE_MAX, ctx=ctx) 
  File "/Users/rmcgibbo/miniconda/envs/3.4.2/lib/python3.4/multiprocessing/synchronize.py", line 60, in __init__ 
    unlink_now) 
OSError: [Errno 28] No space left on device 

(注意,这似乎不依赖于 python 的版本。与 2.7.9 相同的错误)

请您参考如下方法:

根据 MacOSX manuals ,用于创建信号量的 sem_open 系统调用可能因 ENOSPC 而失败:

 [ENOSPC]           O_CREAT is specified, the file does not exist, and 
                    there is insufficient space available to create the 
                    semaphore. 

我建议您使用 dtruss 找出 Python 试图在何处创建此信号量。