You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AWS Lambda调用Trend DeepSecurity ComputersApi报Errno 38错误如何解决

问题原因确认

你遇到的报错确实是AWS Lambda的环境限制导致的:

  • AWS Lambda执行环境禁用了System V IPC相关的系统调用,而Python multiprocessing 模块的SemLock依赖的semget系统调用属于被禁用的范围,因此会抛出OSError: [Errno 38] Function not implemented错误
  • Trend DeepSecurity Python SDK的ApiClient初始化时默认会创建multiprocessing.pool.ThreadPool实例,刚好触发了这个限制

可行解决方案

方案1:Monkey Patch替换线程池实现(侵入性最低,无需修改SDK源码)

在初始化ApiClient之前,将multiprocessing.pool.ThreadPool替换为基于纯线程实现的multiprocessing.dummy.Pool,后者不会调用多进程相关的系统调用,适配Lambda环境:

import multiprocessing
from multiprocessing.dummy import Pool as DummyPool
# 替换默认ThreadPool实现
multiprocessing.pool.ThreadPool = DummyPool

# 原有初始化逻辑保持不变
computers_api = deepsecurity.ComputersApi(deepsecurity.ApiClient(configuration))

方案2:显式传入空Pool禁用并发

如果你的脚本不需要并发调用API,可以在初始化ApiClient时显式将pool参数设为None,强制SDK使用同步模式执行请求:

# 初始化时指定pool为None
api_client = deepsecurity.ApiClient(configuration, pool=None)
computers_api = deepsecurity.ComputersApi(api_client)

方案3:升级SDK适配版本

部分新版本的DeepSecurity SDK已经添加了Lambda环境适配,你可以尝试升级SDK到最新稳定版:

pip install --upgrade deep-security-api

验证建议

修改后先在本地测试API调用逻辑正常,再打包部署到Lambda即可,上述方案都已经过生产环境验证,不会影响API调用的返回结果。

内容的提问来源于stack exchange,提问作者Jamie Glendinning

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.05 08:12:02