Skip to content
Advertisement

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.

JavaScript

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.

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.

Edit: I should note that the problem also happens under the pure-python werkzeug server.

Advertisement

Answer

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. In our code base, there is one line code:

JavaScript

It is part of a class’s __init__(). Anytime a new object was created, os.environ got longer, eventually it became “too long”.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement