IOError: [Errno 90] Message too long
uWSGI does not handle properly printing to stdout big strings when using logger option.
$ uwsgi --version 2.0.13.1
$ uname -a Linux 4.4.0-22-generic #40-Ubuntu SMP Thu May 12 22:03:46 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
Example:
$ rm -f /tmp/uwsgi.log; uwsgi --http=:9090 --logger=file:/tmp/uwsgi.log --eval='print "x" * 300000'; tail /tmp/uwsgi.log
Python version: 2.7.11+ (default, Apr 17 2016, 14:00:29) [GCC 5.3.1 20160413]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x144f9c0
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 145536 bytes (142 KB) for 1 cores
*** Operational MODE: single process ***
Traceback (most recent call last):
File "uwsgi_eval_config", line 1, in
Maybe it is the same reason as in #1266 - stdout is set as nonblocking.
Errno 90 == EMSGSIZE and https://linux.die.net/man/2/send: EMSGSIZE The socket type requires that message be sent atomically, and the size of the message to be sent made this impossible.
Any ideas?
If we set option log-master-stream = true than we have error from issue #1266
any news ?..
Received same issue in our app recently. we have
master = True
daemonize = true
# logging
logger = file:Path to log file
# clear environment on exit
vacuum = true
any news on this guys?
I've finally found a workaround. Set the option --log-master-bufsize to a value bigger than printed string (for example 1000000). Default is 8192.
I've finally found a workaround. Set the option
--log-master-bufsizeto a value bigger than printed string (for example 1000000). Default is 8192.
This did not work for me. I added three zeros on top of 1000000. Still gives same error.
Is there any progress on a solution or a workaround for this?
The only solution I found is to use logger or logging module in python instead of using print. It won't throw an exception similar to the print function. The other way to built a pseudo_print function which catches the exception and clears the buffer and not break the code.
@sindhujit1 Oddly, it's python logging call, with a large message payload, that is causing the error for me.
it may show logging error but it should not break your code. When I tried it, the execution continues at the next line. Example:
logging.warning("leafxmlarray is %s"+str(leafxmlarray))
print("test print")
Given that leafxmlarray is a huge list which shows the "message too long" error, the "test print" prints fine in my console and code execution continues.
Just tested on uwsgi 2.0.28, python 3.12:
- This fails:
$ rm -f /tmp/uwsgi.log; uwsgi --http=:9090 --logger=file:/tmp/uwsgi.log --eval='print("x\n" * 3
00000)'; tail -3 /tmp/uwsgi.log
Traceback (most recent call last):
File "uwsgi_eval_config", line 1, in <module>
OSError: [Errno 90] Message too long
- This does not fail:
$ rm -f /tmp/uwsgi.log; uwsgi --http=:9090 --logger=file:/tmp/uwsgi.log --eval='print("x\n" * 3
00000)' --log-master-stream; tail -3 /tmp/uwsgi.log
x
x
x
So, the workaround is to set log-master-stream option (and maybe log-master-bufsize if needed).