Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.

Log SystemExit in wsgi middleware when code != 0 - #686

Merged
mitsuhiko merged 2 commits into
masterfrom
systemexit
Nov 13, 2015
Merged

mitsuhiko merged 2 commits into
masterfrom
systemexit

Conversation

@mattrobenolt

Copy link
Copy Markdown
Contributor

SystemExit does not subclass Exception, so we don't catch this.
SystemExit manifests itself (at least) from gunicorn when gunicorn
attempts to gracefully shut down a worker process. See GH-675 for more
background.

Fixes: GH-675

SystemExit does not subclass Exception, so we don't catch this.
SystemExit manifests itself (at least) from gunicorn when gunicorn
attempts to gracefully shut down a worker process. See GH-675 for more
background.

Fixes: GH-675
@dcramer

dcramer commented Nov 13, 2015

Copy link
Copy Markdown
Member

This might cause some duplicate events, but otherwise seems fine

@mattrobenolt

Copy link
Copy Markdown
Contributor Author

In what cases do you think it'd cause duplicate events?

@dcramer

dcramer commented Nov 13, 2015

Copy link
Copy Markdown
Member

If this propagates up to the system hook

@mattrobenolt

Copy link
Copy Markdown
Contributor Author

Ah, lemme test that out and see what actually happens there. Not sure if the system hook ignores a SystemExit or not. My hunch is "yes", considering these errors weren't getting captured before.

@mattrobenolt

Copy link
Copy Markdown
Contributor Author
import sys

def hook(*exc_info):
    print 'going down'

sys.excepthook = hook

raise SystemExit(1)

excepthook ignores SystemExit

@mitsuhiko
mitsuhiko merged commit 5be739c into master Nov 13, 2015
mitsuhiko added a commit that referenced this pull request Nov 13, 2015
@mitsuhiko

Copy link
Copy Markdown
Contributor

Merged and also log KeyboardInterrupt which is currently also not handled. This serves a similar purpose for other servers.

@mattrobenolt
mattrobenolt deleted the systemexit branch April 20, 2016 21:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants