Commit 41a695a7 authored by Ralf Schmitt's avatar Ralf Schmitt

handle EMFILE error (too many open files) gracefully while accepting new clients.

--HG--
extra : transplant_source : %F3%93%87q%87a%18Z7%09%F3%87%3C1%25%60%D3%EB%11o
parent c1b7cee8
......@@ -27,7 +27,7 @@ import time
import traceback
from urllib import unquote
from gevent import socket
from gevent import socket, sleep
import BaseHTTPServer
from gevent.pool import Pool
from gevent.greenlet import Greenlet
......@@ -414,6 +414,12 @@ def server(sock, site, log=None, environ=None, max_size=None, max_http_version=D
try:
client_socket = sock.accept()
except socket.error, e:
if e[0] == errno.EMFILE:
# we ran out of file descriptors and will call accept in a busy loop...
# ...which we avoid by sleeping a bit
print "WARNING: pywsgi: out of file descriptors. cannot accept outstanding connections."
sleep(1.0)
continue
if e[0] != errno.EPIPE and e[0] != errno.EBADF:
raise
pool.spawn(serv.process_request, client_socket)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment