Skip to content

Commit

Permalink
Nice preset. Added ignore_write_errors shortcut support.
Browse files Browse the repository at this point in the history
  • Loading branch information
idlesign committed Oct 31, 2017
1 parent 4192e9a commit d564cff
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ uwsgiconf changelog

Unreleased
----------
+ Nice preset. Added 'ignore_write_errors' shortcut support.
+ CLI. Added headers related methods to routing options group.
+ Added 'master_process.set_exception_handling_params'.
* 'Logging.set_filters' split into 'set_filters' and 'set_requests_filters'.
Expand Down
9 changes: 9 additions & 0 deletions tests/presets/test_nice.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ def test_nice_section(assert_lines):

], Section(workers=13, touch_reload=__file__))

assert_lines([
'disable-write-exception = true',
'ignore-write-errors = true',
'ignore-sigpipe = true',
'log-master = true',
'threaded-logger = true',

], Section(log_dedicated=True, ignore_write_errors=True))


def test_nice_python(assert_lines):

Expand Down
13 changes: 12 additions & 1 deletion uwsgiconf/presets/nice.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ class Section(_Section):

def __init__(
self, name=None, touch_reload=None, workers=None, threads=None, mules=None, owner=None,
log_into=None, process_prefix=None, log_dedicated=None, **kwargs):
log_into=None, process_prefix=None, log_dedicated=None, ignore_write_errors=None,
**kwargs):
"""
:param str|unicode name: Section name.
Expand All @@ -29,6 +30,12 @@ def __init__(
:param bool log_dedicated: If ``True`` all logging will be handled with a separate
thread in master process.
:param bool ignore_write_errors: If ``True`` no annoying SIGPIPE/write/writev errors
will be logged, and no related exceptions will be raised.
.. note:: Usually such errors could be seen on client connection cancelling
and are safe to ignore.
:param kwargs:
"""
super(Section, self).__init__(strict_config=True, name=name, **kwargs)
Expand Down Expand Up @@ -68,6 +75,10 @@ def __init__(
self.configure_owner(owner=owner)
self.logging.log_into(target=log_into)

if ignore_write_errors:
self.master_process.set_exception_handling_params(no_write_exception=True)
self.logging.set_filters(write_errors=False, sigpipe=False)

def configure_owner(self, owner='www-data'):
"""Shortcut to set process owner data.
Expand Down

0 comments on commit d564cff

Please sign in to comment.