OSError:[Errno 24] python导入时打开的文件太多

时间:2018-11-08 11:54:44

标签: linux python-3.x

我有一个测试环境,可以使用以下命令从C代码中调用python:

ActiveRecord

运行很长时间后,每次都会出现此错误:

system("flows_parser.py ....");
输入proto_steps_common_steps_defines_pb2中的

flows_parser.py第32行 proto_steps_common_steps_defines_pb2.py第9行也是反射的导入。

我在Ubuntu 16.4上 输出:sysctl -A | grep shm

Traceback (most recent call last):
  File "/homes/fw/antvai01/work/cc312r2/cc_validation/hta/flows_parser/flows_parser.py", line 32, in <module>
  File "/homes/fw/antvai01/work/cc312r2/cc_validation/hta/flows_parser/../../shared/proto_steps/common/generated_py/proto_steps_common_steps_defines_pb2.py", line 9, in <module>
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 661, in exec_module
  File "<frozen importlib._bootstrap_external>", line 766, in get_code
  File "<frozen importlib._bootstrap_external>", line 818, in get_data
OSError: [Errno 24] Too many open files: '/usr/local/lib/python3.5/dist-packages/google/protobuf/reflection.py'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 661, in exec_module
  File "<frozen importlib._bootstrap_external>", line 766, in get_code
  File "<frozen importlib._bootstrap_external>", line 818, in get_data
OSError: [Errno 24] Too many open files: '/usr/lib/python3/dist-packages/apport/__init__.py'

Original exception was:
Traceback (most recent call last):
  File "/homes/fw/antvai01/work/cc312r2/cc_validation/hta/flows_parser/flows_parser.py", line 32, in <module>
  File "/homes/fw/antvai01/work/cc312r2/cc_validation/hta/flows_parser/../../shared/proto_steps/common/generated_py/proto_steps_common_steps_defines_pb2.py", line 9, in <module>
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 661, in exec_module
  File "<frozen importlib._bootstrap_external>", line 766, in get_code
  File "<frozen importlib._bootstrap_external>", line 818, in get_data
OSError: [Errno 24] Too many open files: '/usr/local/lib/python3.5/dist-packages/google/protobuf/reflection.py'

所以shmmax应该不是问题。 有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

感谢里卡多·布兰科! 它是C代码中的描述子韭菜,与python无关。 我创建了管道,完成后并没有关闭它们。 我找到了韭菜描述符,并将其插入,现在可以正常工作了。