Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOError: [Errno 11] Resource temporarily unavailable #1266

Open
marc1n opened this issue May 25, 2016 · 6 comments
Open

IOError: [Errno 11] Resource temporarily unavailable #1266

marc1n opened this issue May 25, 2016 · 6 comments

Comments

@marc1n
Copy link

marc1n commented May 25, 2016

uWSGI is failing when logging big string to stream logger (got EAGAIN from logger socket)

$ 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

uwsgi.ini:

[uwsgi]
http-socket = :9090
processes = 2
logger = file:/tmp/uwsgi.log
log-master-stream = true 
wsgi-file=app.py

app.py:

def application(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/plain')])
    print 'x\n' * (1024 * 1024)
    return ['Hello']
  1. Run uWSGI:
    $ pkill -9 uwsgi; pgrep uwsgi; rm -f /tmp/uwsgi.log; uwsgi --ini=uwsgi.ini
    [uWSGI] getting INI configuration from uwsgi.ini
  2. From other terminal (sometimes error does not happen):
    $ curl http://localhost:9090; tail /tmp/uwsgi.log
    x
    x
    x
    x
    x
    Traceback (most recent call last):
    File "app.py", line 7, in application
    print big_log
    IOError: [Errno 11] Resource temporarily unavailable
    [pid: 23479|app: 0|req: 1/2] 127.0.0.1 () {24 vars in 249 bytes} [Wed May 25 11:25:27 2016] GET / => generated 0 bytes in 0 msecs (HTTP/1.1 200) 1 headers in 45 bytes (0 switches on core 0)
@marc1n
Copy link
Author

marc1n commented Oct 23, 2016

Any ideas?

@marc1n
Copy link
Author

marc1n commented Oct 25, 2016

Error happened event if I print 128kB data:

def application(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
print 'x\n' * (128 * 1024)
return ['Hello']

pkill -9 uwsgi; pgrep uwsgi; rm -f /tmp/uwsgi.log; uwsgi --ini=uwsgi.ini

curl http://localhost:9090 && tail /tmp/uwsgi.log

x
x
x
x
x
x
x
x
IOError: [Errno 11] Resource temporarily unavailable
[pid: 14245|app: 0|req: 1/1] 127.0.0.1 () {24 vars in 244 bytes} [Tue Oct 25 12:56:44 2016] GET / => generated 0 bytes in 0 msecs (HTTP/1.1 200) 1 headers in 45 bytes (0 switches on core 0)

@marc1n
Copy link
Author

marc1n commented Oct 25, 2016

Probable reason is that uWSGI set stdout stream as non blocking if we set 'logger' option.

Errno 11 == EAGAIN and https://linux.die.net/man/2/send:
When the message does not fit into the send buffer of the socket, send() normally blocks, unless the socket has been placed in nonblocking I/O mode. In nonblocking mode it would fail with the error EAGAIN or EWOULDBLOCK in this case.

@marc1n
Copy link
Author

marc1n commented Jan 12, 2018

If the option log-master-stream is false than there is other error: "[Errno 90] Message too long" (issue #1265):

Traceback (most recent call last):
File "app.py", line 3, in application
print 'x\n' * (1024 * 1024)
IOError: [Errno 90] Message too long

@marc1n
Copy link
Author

marc1n commented May 8, 2020

I've finally found a workaround. Set option log-master-bufsize to value bigger than printed string (for example 2048577). Default is 8192.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant