python 外部参数过长_Linux中的Python OSError No 7(参数列表过长)

I am trying to open a new subprocess which will take a few input files and generate the output in other file. While this runs cleanly most of the times, when I am trying to do some stress testing this fails and gives me the following error trace:

File "/home/admin/Workspace/.metadata/.plugins/org.eclipse.pde.core/pde-junit/org.eclipse.osgipython/util/media_info.py", line 161, in external_process

process = subprocess.Popen(command, shell=shell, close_fds=True, stderr=subprocess.PIPE)

File "/usr/local/lib/python2.6/subprocess.py", line 623, in __init__

errread, errwrite)

File "/usr/local/lib/python2.6/subprocess.py", line 1141, in _execute_child

raise child_exception

OSError: [Errno 7] Argument list too long

Initially I thought that the command that I was passing(it was the absolute path of 4 files) was longer than the OS could support. But even after reducing the absolute path passed to 1/4th of the original value. I still get this error. Please note that I don't get this error all the time. Mostly its after a 1000 or more runs while the path length remains the same for all cases.

解决方案

strace is your friend. Throw in a -s 2048 to see what's really happening. Knowing C will help you read this, but you can still pick out long exec* strings without C knowledge.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值