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

revert: 4023228 ("let's exception not bubble") #3275

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion gunicorn/workers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

class Worker:

WORKAROUND_BASE_EXCEPTIONS = () # none

SIGNALS = [getattr(signal, "SIG%s" % x) for x in (
"ABRT HUP QUIT INT TERM USR1 USR2 WINCH CHLD".split()
)]
Expand Down Expand Up @@ -262,7 +264,7 @@ def handle_error(self, req, client, addr, exc):
if hasattr(req, "uri"):
self.log.exception("Error handling request %s", req.uri)
else:
self.log.exception("Error handling request (no URI read)")
self.log.debug("Error handling request (no URI read)")
status_int = 500
reason = "Internal Server Error"
mesg = ""
Expand Down
6 changes: 5 additions & 1 deletion gunicorn/workers/base_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ def handle(self, listener, client, addr):
self.log.debug("Ignoring socket not connected")
else:
self.log.debug("Ignoring EPIPE")
except BaseException as e:
except self.WORKAROUND_BASE_EXCEPTIONS as e:
self.log.warning("Catched async exception (compat workaround). "
"If this is not a bug in your app, please file a report.")
self.handle_error(req, client, addr, e)
except Exception as e:
self.handle_error(req, client, addr, e)
finally:
util.close(client)
Expand Down
2 changes: 2 additions & 0 deletions gunicorn/workers/geventlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ def patch_sendfile():

class EventletWorker(AsyncWorker):

WORKAROUND_BASE_EXCEPTIONS = (eventlet.Timeout, )

def patch(self):
hubs.use_hub()
eventlet.monkey_patch()
Expand Down
2 changes: 2 additions & 0 deletions gunicorn/workers/ggevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

class GeventWorker(AsyncWorker):

WORKAROUND_BASE_EXCEPTIONS = (gevent.Timeout, )

server_class = None
wsgi_handler = None

Expand Down
4 changes: 3 additions & 1 deletion gunicorn/workers/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ def run_for_multiple(self, timeout):
return

def run(self):
assert len(self.WORKAROUND_BASE_EXCEPTIONS) == 0

# if no timeout is given the worker will never wait and will
# use the CPU for nothing. This minimal timeout prevent it.
timeout = self.timeout or 0.5
Expand Down Expand Up @@ -153,7 +155,7 @@ def handle(self, listener, client, addr):
self.log.debug("Ignoring socket not connected")
else:
self.log.debug("Ignoring EPIPE")
except BaseException as e:
except Exception as e:
self.handle_error(req, client, addr, e)
finally:
util.close(client)
Expand Down
Loading