python-Werkzeug/0001_create_a_thread_to_reap_death_process.patch

66 lines
2.1 KiB
Diff
Raw Normal View History

Accepting request 358349 from home:aplanas:branches:devel:languages:python - Add 0001_create_a_thread_to_reap_death_process.patch Fixes bsc#954591 - update to 0.11.3: - Added reloader_paths option to run_simple and other functions in werkzeug.serving. This allows the user to completely override the Python module watching of Werkzeug with custom paths. - Many custom cached properties of Werkzeug’s classes are now subclasses of Python’s property type (issue #616). - bind_to_environ now doesn’t differentiate between implicit and explicit default port numbers in HTTP_HOST (pull request #204). - BuildErrors are now more informative. They come with a complete sentence as error message, and also provide suggestions (pull request #691). - Fix a bug in the user agent parser where Safari’s build number instead of version would be extracted (pull request #703). - Fixed issue where RedisCache set_many was broken for twemproxy, which doesn’t support the default MULTI command (pull request #702). - mimetype parameters on request and response classes are now always converted to lowercase. - Changed cache so that cache never expires if timeout is 0. This also fixes an issue with redis setex (issue #550) - Werkzeug now assumes UTF-8 as filesystem encoding on Unix if Python detected it as ASCII. - New optional has method on caches. - Fixed various bugs in parse_options_header (pull request #643). - If the reloader is enabled the server will now open the socket in the parent process if this is possible. This means that when the reloader kicks in the connection from client will wait instead of OBS-URL: https://build.opensuse.org/request/show/358349 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-Werkzeug?expand=0&rev=16
2016-02-09 10:45:07 +01:00
From 676bc5fa4b6aa9d153c9805cdbad0ff0450bade6 Mon Sep 17 00:00:00 2001
From: Alberto Planas <aplanas@gmail.com>
Date: Wed, 3 Feb 2016 11:56:23 +0100
Subject: [PATCH] Create a thread to reap death process
ForkingWSGIServer use `SocketServer.ForkingMixIn` to implement a
multiprocess server. This class provides a workflow that collect
death process (process in Zombie status) before the
`process_request`. This means that this process itself will be
in Zombie status at the end of the request, that will be eventually
collected during the next `process_request`.
To minimize transient Zombie process, `ForkingWSGIServer` is
creating a daemon thread (via `threading.Timer`) to call the
collector every (by default) 5 seconds.
Fixes #810
---
werkzeug/serving.py | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
Index: Werkzeug-0.15.4/src/werkzeug/serving.py
Accepting request 486169 from devel:languages:python:singlespec - update to 0.12.1 - use python3-Sphinx for build - update for singlespec - update to 0.12.1 * deprecate werkzeug.script * Use `inspect.getfullargspec` internally when available as `inspect.getargspec` is gone in 3.6 * Added support for status code 451 and 423 * Improved the build error suggestions. In particular only if someone stringifies the error will the suggestions be calculated. * Added support for uWSGI's caching backend. * Fix a bug where iterating over a `FileStorage` would result in an infinite loop. * Datastructures now inherit from the relevant baseclasses from the `collections` module in the stdlib. See #794. * Add support for recognizing NetBSD, OpenBSD, FreeBSD, DragonFlyBSD platforms in the user agent string. * Recognize SeaMonkey browser name and version correctly * Recognize Baiduspider, and bingbot user agents * If `LocalProxy`'s wrapped object is a function, refer to it with __wrapped__ attribute. * The defaults of ``generate_password_hash`` have been changed to more secure ones, see pull request ``#753``. * Add support for encoding in options header parsing, see pull request ``#933``. * ``test.Client`` now properly handles Location headers with relative URLs, see pull request ``#879``. * When `HTTPException` is raised, it now prints the description, for easier debugging. OBS-URL: https://build.opensuse.org/request/show/486169 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-Werkzeug?expand=0&rev=24
2017-04-06 17:05:56 +02:00
===================================================================
--- Werkzeug-0.15.4.orig/src/werkzeug/serving.py
+++ Werkzeug-0.15.4/src/werkzeug/serving.py
@@ -41,6 +41,7 @@ import signal
Accepting request 358349 from home:aplanas:branches:devel:languages:python - Add 0001_create_a_thread_to_reap_death_process.patch Fixes bsc#954591 - update to 0.11.3: - Added reloader_paths option to run_simple and other functions in werkzeug.serving. This allows the user to completely override the Python module watching of Werkzeug with custom paths. - Many custom cached properties of Werkzeug’s classes are now subclasses of Python’s property type (issue #616). - bind_to_environ now doesn’t differentiate between implicit and explicit default port numbers in HTTP_HOST (pull request #204). - BuildErrors are now more informative. They come with a complete sentence as error message, and also provide suggestions (pull request #691). - Fix a bug in the user agent parser where Safari’s build number instead of version would be extracted (pull request #703). - Fixed issue where RedisCache set_many was broken for twemproxy, which doesn’t support the default MULTI command (pull request #702). - mimetype parameters on request and response classes are now always converted to lowercase. - Changed cache so that cache never expires if timeout is 0. This also fixes an issue with redis setex (issue #550) - Werkzeug now assumes UTF-8 as filesystem encoding on Unix if Python detected it as ASCII. - New optional has method on caches. - Fixed various bugs in parse_options_header (pull request #643). - If the reloader is enabled the server will now open the socket in the parent process if this is possible. This means that when the reloader kicks in the connection from client will wait instead of OBS-URL: https://build.opensuse.org/request/show/358349 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-Werkzeug?expand=0&rev=16
2016-02-09 10:45:07 +01:00
import socket
import sys
Accepting request 486169 from devel:languages:python:singlespec - update to 0.12.1 - use python3-Sphinx for build - update for singlespec - update to 0.12.1 * deprecate werkzeug.script * Use `inspect.getfullargspec` internally when available as `inspect.getargspec` is gone in 3.6 * Added support for status code 451 and 423 * Improved the build error suggestions. In particular only if someone stringifies the error will the suggestions be calculated. * Added support for uWSGI's caching backend. * Fix a bug where iterating over a `FileStorage` would result in an infinite loop. * Datastructures now inherit from the relevant baseclasses from the `collections` module in the stdlib. See #794. * Add support for recognizing NetBSD, OpenBSD, FreeBSD, DragonFlyBSD platforms in the user agent string. * Recognize SeaMonkey browser name and version correctly * Recognize Baiduspider, and bingbot user agents * If `LocalProxy`'s wrapped object is a function, refer to it with __wrapped__ attribute. * The defaults of ``generate_password_hash`` have been changed to more secure ones, see pull request ``#753``. * Add support for encoding in options header parsing, see pull request ``#933``. * ``test.Client`` now properly handles Location headers with relative URLs, see pull request ``#879``. * When `HTTPException` is raised, it now prints the description, for easier debugging. OBS-URL: https://build.opensuse.org/request/show/486169 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-Werkzeug?expand=0&rev=24
2017-04-06 17:05:56 +02:00
+import threading
import werkzeug
from ._compat import PY2
from ._compat import reraise
@@ -775,6 +776,7 @@ class ForkingWSGIServer(ForkingMixIn, Ba
passthrough_errors=False,
ssl_context=None,
fd=None,
+ frequency=5,
):
Accepting request 486169 from devel:languages:python:singlespec - update to 0.12.1 - use python3-Sphinx for build - update for singlespec - update to 0.12.1 * deprecate werkzeug.script * Use `inspect.getfullargspec` internally when available as `inspect.getargspec` is gone in 3.6 * Added support for status code 451 and 423 * Improved the build error suggestions. In particular only if someone stringifies the error will the suggestions be calculated. * Added support for uWSGI's caching backend. * Fix a bug where iterating over a `FileStorage` would result in an infinite loop. * Datastructures now inherit from the relevant baseclasses from the `collections` module in the stdlib. See #794. * Add support for recognizing NetBSD, OpenBSD, FreeBSD, DragonFlyBSD platforms in the user agent string. * Recognize SeaMonkey browser name and version correctly * Recognize Baiduspider, and bingbot user agents * If `LocalProxy`'s wrapped object is a function, refer to it with __wrapped__ attribute. * The defaults of ``generate_password_hash`` have been changed to more secure ones, see pull request ``#753``. * Add support for encoding in options header parsing, see pull request ``#933``. * ``test.Client`` now properly handles Location headers with relative URLs, see pull request ``#879``. * When `HTTPException` is raised, it now prints the description, for easier debugging. OBS-URL: https://build.opensuse.org/request/show/486169 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-Werkzeug?expand=0&rev=24
2017-04-06 17:05:56 +02:00
if not can_fork:
raise ValueError("Your platform does not support forking.")
@@ -783,6 +785,23 @@ class ForkingWSGIServer(ForkingMixIn, Ba
)
Accepting request 358349 from home:aplanas:branches:devel:languages:python - Add 0001_create_a_thread_to_reap_death_process.patch Fixes bsc#954591 - update to 0.11.3: - Added reloader_paths option to run_simple and other functions in werkzeug.serving. This allows the user to completely override the Python module watching of Werkzeug with custom paths. - Many custom cached properties of Werkzeug’s classes are now subclasses of Python’s property type (issue #616). - bind_to_environ now doesn’t differentiate between implicit and explicit default port numbers in HTTP_HOST (pull request #204). - BuildErrors are now more informative. They come with a complete sentence as error message, and also provide suggestions (pull request #691). - Fix a bug in the user agent parser where Safari’s build number instead of version would be extracted (pull request #703). - Fixed issue where RedisCache set_many was broken for twemproxy, which doesn’t support the default MULTI command (pull request #702). - mimetype parameters on request and response classes are now always converted to lowercase. - Changed cache so that cache never expires if timeout is 0. This also fixes an issue with redis setex (issue #550) - Werkzeug now assumes UTF-8 as filesystem encoding on Unix if Python detected it as ASCII. - New optional has method on caches. - Fixed various bugs in parse_options_header (pull request #643). - If the reloader is enabled the server will now open the socket in the parent process if this is possible. This means that when the reloader kicks in the connection from client will wait instead of OBS-URL: https://build.opensuse.org/request/show/358349 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-Werkzeug?expand=0&rev=16
2016-02-09 10:45:07 +01:00
self.max_children = processes
+ if frequency:
+ self.frequency = frequency
+ self.setup_reap_children()
+
+ def setup_reap_children(self):
+ """Create a thread to collect death children."""
+ t = threading.Timer(self.frequency, self.reap_children)
+ # Set daemon mode to provide a clean termination of the thread
+ # when the system ends
+ t.daemon = True
+ t.start()
+
+ def reap_children(self):
+ """Reap or collect death children."""
+ self.collect_children()
+ self.setup_reap_children()
+
def make_server(
host=None,