我有一些可以通过多处理得到改进的代码,但是在AWS Lambda中,/dev/shm
不可用,因此ProcessPoolExecutor
失败,并显示了一条错误消息:
File "/var/task/black.py", line 529, in reformat_many
executor = ProcessPoolExecutor(max_workers=worker_count)
File "/var/lang/lib/python3.7/concurrent/futures/process.py", line 556, in __init__
pending_work_items=self._pending_work_items)
File "/var/lang/lib/python3.7/concurrent/futures/process.py", line 165, in __init__
super().__init__(max_size, ctx=ctx)
File "/var/lang/lib/python3.7/multiprocessing/queues.py", line 42, in __init__
self._rlock = ctx.Lock()
File "/var/lang/lib/python3.7/multiprocessing/context.py", line 67, in Lock
return Lock(ctx=self.get_context())
File "/var/lang/lib/python3.7/multiprocessing/synchronize.py", line 162, in __init__
SemLock.__init__(self, SEMAPHORE, 1, 1, ctx=ctx)
File "/var/lang/lib/python3.7/multiprocessing/synchronize.py", line 59, in __init__
unlink_now)
OSError: [Errno 38] Function not implemented
是否有一种便携式方法可以检测到它会失败?