mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
try to send a response even if something happend
This commit is contained in:
parent
57054f1a4c
commit
ddb48593f3
@ -60,7 +60,17 @@ def write(sock, data):
|
|||||||
break
|
break
|
||||||
raise
|
raise
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
def write_nonblock(sock, data):
|
||||||
|
timeout = sock.gettimeout()
|
||||||
|
if timeout != "0.0":
|
||||||
|
sock.setblockin(0)
|
||||||
|
ret = write(sock, data)
|
||||||
|
sock.setblocking(1)
|
||||||
|
return ret
|
||||||
|
else:
|
||||||
|
return write(sock, data)
|
||||||
|
|
||||||
def writelines(sock, lines):
|
def writelines(sock, lines):
|
||||||
for line in list(lines):
|
for line in list(lines):
|
||||||
write(sock, line)
|
write(sock, line)
|
||||||
|
|||||||
@ -133,7 +133,14 @@ class Worker(object):
|
|||||||
return
|
return
|
||||||
http.HttpResponse(client, response, req).send()
|
http.HttpResponse(client, response, req).send()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
self.log.exception("Error processing request. [%s]" % str(e))
|
self.log.exception("Error processing request. [%s]" % str(e))
|
||||||
|
|
||||||
|
# try to send a response even if something happend
|
||||||
|
try:
|
||||||
|
write_nonblock(sock,
|
||||||
|
"HTTP/1.0 500 Internal Server Error\r\n\r\n")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
finally:
|
finally:
|
||||||
util.close(client)
|
util.close(client)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user