uwsgi icon indicating copy to clipboard operation
uwsgi copied to clipboard

IOError: [Errno 90] Message too long

Open marc1n opened this issue 9 years ago • 12 comments

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 IOError: [Errno 90] Message too long

marc1n avatar May 25 '16 09:05 marc1n

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.

marc1n avatar Oct 25 '16 11:10 marc1n

Any ideas?

marc1n avatar Aug 21 '17 13:08 marc1n

If we set option log-master-stream = true than we have error from issue #1266

marc1n avatar Jan 12 '18 10:01 marc1n

any news ?..

skob avatar Jul 31 '19 06:07 skob

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?

sindhujit avatar Jan 10 '20 00:01 sindhujit

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.

marc1n avatar May 08 '20 09:05 marc1n

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.

This did not work for me. I added three zeros on top of 1000000. Still gives same error.

sindhujit1 avatar Jul 10 '20 20:07 sindhujit1

Is there any progress on a solution or a workaround for this?

silverbucket avatar Feb 25 '25 15:02 silverbucket

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 avatar Feb 25 '25 15:02 sindhujit1

@sindhujit1 Oddly, it's python logging call, with a large message payload, that is causing the error for me.

silverbucket avatar Feb 25 '25 15:02 silverbucket

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.

sindhujit1 avatar Feb 25 '25 18:02 sindhujit1

Just tested on uwsgi 2.0.28, python 3.12:

  1. 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

  1. 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).

marc1n avatar Feb 25 '25 21:02 marc1n