-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add middleware that apps can use to handle graceful timeout signal
uwsgi 2.0.22+ offers option to send a user-defined signal at for a "graceful" timeout before the real harakiri occurs. gunicorn sends SIGABRT (signal 6) as graceful timeout signal before sending SIGKILL Apps can use this middleware to log a traceback indicating what code was executing when the graceful timeout signal was received.
- Loading branch information
Showing
8 changed files
with
81 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from ansible_base.lib.middleware.logging.log_request import LogRequestMiddleware | ||
from ansible_base.lib.middleware.logging.log_request import LogRequestMiddleware, LogTracebackMiddleware | ||
|
||
__all__ = ('LogRequestMiddleware',) | ||
__all__ = ('LogRequestMiddleware', 'LogTracebackMiddleware') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
test_app/tests/lib/logging/middleware/test_traceback_logger.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from unittest import TestCase, mock | ||
|
||
from django.http import HttpRequest | ||
|
||
from ansible_base.lib.middleware.logging.log_request import LogTracebackMiddleware | ||
|
||
|
||
class TestLogTracebackMiddleware(TestCase): | ||
def test_log_traceback_middleware(self): | ||
get_response = mock.MagicMock() | ||
request = HttpRequest() | ||
request.method = "GET" | ||
request.path = "/test" | ||
|
||
middleware = LogTracebackMiddleware(get_response) | ||
response = middleware(request) | ||
|
||
# ensure get_response has been returned | ||
self.assertEqual(get_response.return_value, response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters