简体   繁体   English

间歇性“OSError: [Errno 7] Argument list too long”和短命令(~125 个字符)

[英]Intermittent “OSError: [Errno 7] Argument list too long” with short command (~125 chars)

This code running under apache2+mod_wsgi on Linux sometimes produces the following output.此代码在 Linux 上的 apache2+mod_wsgi 下运行有时会产生以下输出。

   notes.py
            cmd_list = [
                    'abc_generate_pdf',
                    '--cdb-url-prefix', model.config('cdb_url_prefix'),
                    '--request-cid', request_cid,
            ]
            log.info("About to run: {!r}".format(cmd_list))
            subprocess.Popen(cmd_list)
...
2014-07-16 11:03:44,779 INFO     pid:17925,140353357215488 abc.webapp.check.notes:198:approval_revoke About to run: ['abc_generate_pdf', '--cdb-url-prefix', 'xxxxdev', '--request-cid', u'xxxxx_xxx_2014-07-15_16.12.50.108807_685932a62c7c6226987acdeda367dbc3']
2014-07-16 11:03:45,250 ERROR    pid:17925,140353357215488 abc.webapp.check.notes:208:approval_revoke Unknown error; approval not updated.
Traceback (most recent call last):
  File "/home/abc/abc/webapp/check/notes.py", line 199, in approval_revoke
    subprocess.Popen(cmd_list)
  File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
    raise child_exception
OSError: [Errno 7] Argument list too long

The output has been anonymized slightly, but the character counts remain exact.输出已略微匿名,但字符数保持准确。

The problem seems to happen after the web server has been running for a long time, and goes away with a restart, however it's difficult to pin down exactly what the trigger might be.该问题似乎发生在 Web 服务器运行了很长时间之后,并随着重新启动而消失,但是很难确定触发因素可能是什么。

Why am I getting an error, and what can I do to prevent it?为什么我会收到错误消息,我可以做些什么来防止它?

This question is very similar to Python OSError no 7 (Argument list too long ) in linux , which doesn't have a satisfactory answer.这个问题非常类似于Linux中的Python OSError no 7 (Argument list too long),没有一个令人满意的答案。

Edit: I should note that the problem also happens under the pure-python werkzeug server.编辑:我应该注意到这个问题也发生在纯 python werkzeug 服务器下。

We had a similar problem and bothered us for a quite while too.我们也遇到了类似的问题,也困扰了我们一段时间。 Today, we found the root cause.今天,我们找到了根本原因。

The error message is little bit misleading, it is not command line's "argument" too long, it is actually the OS environment passed along with command.错误信息有点误导,它不是命令行的“参数”太长,它实际上是与命令一起传递的操作系统环境。 In this case, Python os.environ.在这种情况下,Python os.environ。 In our code base, there is one line code:在我们的代码库中,只有一行代码:

os.environ['PATH'] =  ':'.join([os.environ['PATH'], self.clitoolsdir])

It is part of a class's __init__() .它是类的__init__() Anytime a new object was created, os.environ got longer, eventually it became "too long". os.environ创建新对象时, os.environ变长,最终变得“太长”。

This code running under apache2+mod_wsgi on Linux sometimes produces the following output.在Linux上的apache2 + mod_wsgi下运行的这段代码有时会产生以下输出。

   notes.py
            cmd_list = [
                    'abc_generate_pdf',
                    '--cdb-url-prefix', model.config('cdb_url_prefix'),
                    '--request-cid', request_cid,
            ]
            log.info("About to run: {!r}".format(cmd_list))
            subprocess.Popen(cmd_list)
...
2014-07-16 11:03:44,779 INFO     pid:17925,140353357215488 abc.webapp.check.notes:198:approval_revoke About to run: ['abc_generate_pdf', '--cdb-url-prefix', 'xxxxdev', '--request-cid', u'xxxxx_xxx_2014-07-15_16.12.50.108807_685932a62c7c6226987acdeda367dbc3']
2014-07-16 11:03:45,250 ERROR    pid:17925,140353357215488 abc.webapp.check.notes:208:approval_revoke Unknown error; approval not updated.
Traceback (most recent call last):
  File "/home/abc/abc/webapp/check/notes.py", line 199, in approval_revoke
    subprocess.Popen(cmd_list)
  File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
    raise child_exception
OSError: [Errno 7] Argument list too long

The output has been anonymized slightly, but the character counts remain exact.输出已略微匿名化,但字符数保持准确。

The problem seems to happen after the web server has been running for a long time, and goes away with a restart, however it's difficult to pin down exactly what the trigger might be.该问题似乎是在Web服务器运行了很长时间之后发生的,并且随着重新启动而消失了,但是很难确切地确定触发器可能是什么。

Why am I getting an error, and what can I do to prevent it?为什么会出现错误,我该怎么办?

This question is very similar to Python OSError no 7 (Argument list too long ) in linux , which doesn't have a satisfactory answer.这个问题与linux中的Python OSError no 7(参数列表过长)非常相似,后者没有令人满意的答案。

Edit: I should note that the problem also happens under the pure-python werkzeug server.编辑:我应该注意,在纯python werkzeug服务器下也会出现该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 OSError: [Errno 7] 参数列表太长:'php' - Python 3.6 - OSError: [Errno 7] Argument list too long: 'php' - Python 3.6 OSError:[Errno 7] ubuntu上的参数列表太长,python用popen调用bitcoind-cli - OSError: [Errno 7] Argument list too long on ubuntu, python calling bitcoind-cli with popen 为什么我收到 OSError: [Errno 7] 参数列表太长:b'/usr/local/bin/git'? - Why I`m getting OSError: [Errno 7] Argument list too long: b'/usr/local/bin/git'? Linux OS中的Python OSError no 7(参数列表太长) - Python OSError no 7 (Argument list too long ) in linux 为什么在使用mrjob v0.4.4时,[Errno 7]参数列表过长且OSError:[Errno 24]打开的文件太多? - Why am I getting [Errno 7] Argument list too long and OSError: [Errno 24] Too many open files when using mrjob v0.4.4? OSError:[Errno 36]文件名太长: - OSError: [Errno 36] File name too long: OSError: [Errno 63] 文件名太长 - OSError: [Errno 63] File name too long OSError:[Errno 63] JSON 文件(python)中的文件名太长 - OSError: [Errno 63] File name too long in JSON FILE (python) 如何处理OSError:[Errno 36]文件名太长 - How to handle OSError: [Errno 36] File name too long OSError: [Errno 22] 使用命令提示符打开 Jupyter Notebook 的参数无效 - OSError: [Errno 22] Invalid argument opening Jupyter Notebook with Command Prompt
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM