diff options
author | Andrej Shadura <andrew.shadura@collabora.co.uk> | 2019-09-12 17:15:44 +0200 |
---|---|---|
committer | Andrej Shadura <andrew.shadura@collabora.co.uk> | 2019-09-12 17:15:44 +0200 |
commit | 640b45315647d9224f6c275868c312144a46eacb (patch) | |
tree | 1a2a3fda0580b427f8f4ea154fb8ff16d163e263 | |
parent | 4423bbfc290ef05e977607b5dc442a06e2f2f4e9 (diff) | |
parent | f6a44ae82efcfe44c18b26846476fcd3c7570ee3 (diff) |
Update upstream source from tag 'upstream/1.3.0+git20170419+82ac44a'
Update to upstream version '1.3.0+git20170419+82ac44a'
with Debian dir b8faabae9a2a348f2e79aff5eba7060cfbee3793
-rw-r--r-- | .travis.yml | 30 | ||||
-rw-r--r-- | README.rst | 17 | ||||
-rw-r--r-- | chaussette/backend/__init__.py | 11 | ||||
-rw-r--r-- | chaussette/backend/_bjoern.py | 2 | ||||
-rw-r--r-- | chaussette/backend/_eventlet.py | 6 | ||||
-rw-r--r-- | chaussette/backend/_fastgevent.py | 2 | ||||
-rw-r--r-- | chaussette/backend/_gevent.py | 3 | ||||
-rw-r--r-- | chaussette/backend/_geventwebsocket.py | 2 | ||||
-rw-r--r-- | chaussette/backend/_meinheld.py | 8 | ||||
-rw-r--r-- | chaussette/backend/_tornado.py | 2 | ||||
-rw-r--r-- | chaussette/backend/_waitress.py | 13 | ||||
-rw-r--r-- | chaussette/backend/_wsgiref.py | 2 | ||||
-rw-r--r-- | chaussette/server.py | 18 | ||||
-rw-r--r-- | chaussette/tests/test_backend.py | 2 | ||||
-rw-r--r-- | chaussette/tests/test_server.py | 19 | ||||
-rw-r--r-- | docs/source/index.rst | 20 | ||||
-rw-r--r-- | setup.py | 2 | ||||
-rw-r--r-- | tox.ini | 71 |
18 files changed, 126 insertions, 104 deletions
diff --git a/.travis.yml b/.travis.yml index 365a852..a5f2a6b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,29 @@ language: python python: - - "2.7" -before_install: - - sudo apt-get install -y libevent-dev libev-dev + - "3.5" +sudo: false +matrix: + - python: 2.7 + env: TOX_ENV=py27 + - python: 3.5 + env: TOX_ENV=py35 + - python: 3.5 + env: TOX_ENV=flake8 + - python: 3.5 + env: TOX_ENV=docs +addons: + apt: + packages: + - libev-dev + - libevent-dev install: - - python setup.py develop - - pip install tox + - python setup.py develop + - pip install tox script: tox +after_success: + - pip install coveralls + - coveralls notifications: email: tarek@mozilla.com irc: "irc.freenode.org#mozilla-circus" on_success: change -after_success: - # Report coverage results to coveralls.io - - pip install coveralls coverage - - coveralls @@ -12,10 +12,19 @@ under a process and socket manager, such as Circus_. :alt: Build Status :target: https://secure.travis-ci.org/circus-tent/chaussette/ -.. image:: https://coveralls.io/repos/circus-tent/chaussette/badge.png?branch=master +.. image:: https://coveralls.io/repos/circus-tent/chaussette/badge.svg?branch=master :alt: Coverage Status on master :target: https://coveralls.io/r/circus-tent/chaussette?branch=master +.. image:: https://img.shields.io/pypi/v/chaussette.svg + :target: https://python.org/pypi/chaussette/ + +.. image:: https://img.shields.io/pypi/dm/chaussette.svg + :target: https://python.org/pypi/chaussette/ + +.. image:: http://allmychanges.com/p/python/chaussette/badge/ + :target: http://allmychanges.com/p/python/chaussette/?utm_source=badge + Quick Start ----------- @@ -60,17 +69,17 @@ backends: In these examples, we start a standalone WSGI server, but the spirit of chaussette is to be managed by Circus_, as described -http://chaussette.readthedocs.org/en/latest/#using-chaussette-in-circus +https://chaussette.readthedocs.io/en/latest/#using-chaussette-in-circus Links ----- -- The full documentation is located at: http://chaussette.readthedocs.org +- The full documentation is located at: https://chaussette.readthedocs.io - You can reach us for any feedback, bug report, or to contribute, at https://github.com/circus-tent/chaussette -.. _Circus: http://circus.readthedocs.org +.. _Circus: https://circus.readthedocs.io .. _Django: https://docs.djangoproject.com .. _flask: http://flask.pocoo.org/ diff --git a/chaussette/backend/__init__.py b/chaussette/backend/__init__.py index 9529c10..b07bff6 100644 --- a/chaussette/backend/__init__.py +++ b/chaussette/backend/__init__.py @@ -30,6 +30,11 @@ try: except ImportError: pass +try: + from chaussette.backend import _eventlet + _backends['eventlet'] = _eventlet.Server +except ImportError: + pass PY3 = sys.version_info[0] == 3 @@ -56,12 +61,6 @@ if not PY3: pass try: - from chaussette.backend import _eventlet - _backends['eventlet'] = _eventlet.Server - except ImportError: - pass - - try: from chaussette.backend import _socketio _backends['socketio'] = _socketio.Server except ImportError: diff --git a/chaussette/backend/_bjoern.py b/chaussette/backend/_bjoern.py index 83c85cb..220d332 100644 --- a/chaussette/backend/_bjoern.py +++ b/chaussette/backend/_bjoern.py @@ -5,7 +5,7 @@ import bjoern class Server(object): def __init__(self, listener, application=None, backlog=None, - socket_type=None, address_family=None): + socket_type=None, address_family=None, **kw): host, port = listener self.app = application self.sock = create_socket(host, port, address_family, diff --git a/chaussette/backend/_eventlet.py b/chaussette/backend/_eventlet.py index 1ad60f5..95b95c6 100644 --- a/chaussette/backend/_eventlet.py +++ b/chaussette/backend/_eventlet.py @@ -10,10 +10,12 @@ class Server(object): def __init__(self, listener, application=None, backlog=2048, socket_type=socket.SOCK_STREAM, - address_family=socket.AF_INET): + address_family=socket.AF_INET, + disable_monkeypatch=False): self.address_family = address_family self.socket_type = socket_type - eventlet.monkey_patch() + if not disable_monkeypatch: + eventlet.monkey_patch() host, port = listener self.socket = create_socket(host, port, self.address_family, self.socket_type, backlog=backlog) diff --git a/chaussette/backend/_fastgevent.py b/chaussette/backend/_fastgevent.py index 57d8b23..b4e43d4 100644 --- a/chaussette/backend/_fastgevent.py +++ b/chaussette/backend/_fastgevent.py @@ -15,7 +15,7 @@ class Server(WSGIServer): spawn='default', log='default', handler_class=None, environ=None, socket_type=socket.SOCK_STREAM, address_family=socket.AF_INET, graceful_timeout=None, - **ssl_args): + disable_monkeypatch=False, **ssl_args): host, port = listener self.socket = create_socket(host, port, self.address_family, self.socket_type, backlog=backlog) diff --git a/chaussette/backend/_gevent.py b/chaussette/backend/_gevent.py index 5485dd2..0bba098 100644 --- a/chaussette/backend/_gevent.py +++ b/chaussette/backend/_gevent.py @@ -21,7 +21,8 @@ class Server(WSGIServer): def __init__(self, listener, application=None, backlog=None, spawn='default', log='default', handler_class=None, environ=None, socket_type=None, address_family=None, - graceful_timeout=None, **ssl_args): + graceful_timeout=None, disable_monkeypatch=False, + **ssl_args): if address_family: self.address_family = address_family if socket_type: diff --git a/chaussette/backend/_geventwebsocket.py b/chaussette/backend/_geventwebsocket.py index a5a94ed..4409a0f 100644 --- a/chaussette/backend/_geventwebsocket.py +++ b/chaussette/backend/_geventwebsocket.py @@ -15,7 +15,7 @@ class Server(WSGIServer): spawn='default', log='default', handler_class=None, environ=None, socket_type=socket.SOCK_STREAM, address_family=socket.AF_INET, graceful_timeout=None, - **ssl_args): + disable_monkeypatch=False, **ssl_args): self.address_family = address_family self.socket_type = socket_type diff --git a/chaussette/backend/_meinheld.py b/chaussette/backend/_meinheld.py index cae3938..e780377 100644 --- a/chaussette/backend/_meinheld.py +++ b/chaussette/backend/_meinheld.py @@ -6,11 +6,13 @@ from meinheld import server class Server(object): def __init__(self, listener, application=None, backlog=2048, socket_type=socket.SOCK_STREAM, - address_family=socket.AF_INET): + address_family=socket.AF_INET, + disable_monkeypatch=False): self.address_family = address_family self.socket_type = socket_type - from meinheld import patch - patch.patch_all() + if not disable_monkeypatch: + from meinheld import patch + patch.patch_all() server.set_backlog(backlog) host, port = listener if host.startswith('fd://'): diff --git a/chaussette/backend/_tornado.py b/chaussette/backend/_tornado.py index b7a41fe..c7741e6 100644 --- a/chaussette/backend/_tornado.py +++ b/chaussette/backend/_tornado.py @@ -12,7 +12,7 @@ from tornado.wsgi import WSGIApplication class Server(object): def __init__(self, listener, application=None, backlog=2048, socket_type=socket.SOCK_STREAM, - address_family=socket.AF_INET): + address_family=socket.AF_INET, **kw): self.address_family = address_family self.socket_type = socket_type host, port = listener diff --git a/chaussette/backend/_waitress.py b/chaussette/backend/_waitress.py index 4e0f373..ec220df 100644 --- a/chaussette/backend/_waitress.py +++ b/chaussette/backend/_waitress.py @@ -1,5 +1,6 @@ import socket from waitress.server import WSGIServer +import waitress.compat class Server(WSGIServer): @@ -8,7 +9,7 @@ class Server(WSGIServer): def __init__(self, listener, application=None, backlog=2048, socket_type=socket.SOCK_STREAM, - address_family=socket.AF_INET): + address_family=socket.AF_INET, **kw): host, port = listener if host.startswith('fd://'): self._fd = int(host.split('://')[1]) @@ -16,8 +17,14 @@ class Server(WSGIServer): self._fd = None self._chaussette_family_and_type = address_family, socket_type - super(Server, self).__init__(application, backlog=backlog, host=host, - port=port) + # check if waitress has IPv6 support (waitress >= 1.0) + if hasattr(waitress.compat, 'HAS_IPV6'): + ipv6 = address_family == socket.AF_INET6 + super(Server, self).__init__(application, backlog=backlog, + host=host, port=port, ipv6=ipv6) + else: + super(Server, self).__init__(application, backlog=backlog, + host=host, port=port) def create_socket(self, family, type): # Ignore parameters passed by waitress to use chaussette options diff --git a/chaussette/backend/_wsgiref.py b/chaussette/backend/_wsgiref.py index 807e747..e40a169 100644 --- a/chaussette/backend/_wsgiref.py +++ b/chaussette/backend/_wsgiref.py @@ -24,7 +24,7 @@ class ChaussetteServer(WSGIServer): def __init__(self, server_address, app, bind_and_activate=True, backlog=2048, socket_type=socket.SOCK_STREAM, - address_family=socket.AF_INET): + address_family=socket.AF_INET, **kw): self.address_family = address_family self.socket_type = socket_type socketserver.BaseServer.__init__(self, server_address, diff --git a/chaussette/server.py b/chaussette/server.py index 9a8575c..c33c90f 100644 --- a/chaussette/server.py +++ b/chaussette/server.py @@ -11,7 +11,8 @@ from chaussette.backend import get, backends, is_gevent_backend def make_server(app, host=None, port=None, backend='wsgiref', backlog=2048, spawn=None, logger=None, address_family=socket.AF_INET, - socket_type=socket.SOCK_STREAM, graceful_timeout=None): + socket_type=socket.SOCK_STREAM, graceful_timeout=None, + disable_monkeypatch=False): logger = logger or chaussette_logger logger.info('Application is %r' % app) @@ -28,7 +29,9 @@ def make_server(app, host=None, port=None, backend='wsgiref', backlog=2048, 'backlog': backlog, 'address_family': address_family, 'socket_type': socket_type, + 'disable_monkeypatch': disable_monkeypatch } + if spawn is not None: server_class_kwargs['spawn'] = spawn if graceful_timeout is not None: @@ -126,6 +129,10 @@ def main(): choices=backends()) parser.add_argument('--use-reloader', action='store_true', help="Restart server when source files change") + + parser.add_argument('--no-monkey', action='store_true', + help="Disable monkey patching from backend") + parser.add_argument('--spawn', type=int, default=None, help="Spawn type, only makes sense if the backend " "supports it (gevent)") @@ -150,7 +157,11 @@ def main(): help="log output") args = parser.parse_args() - if is_gevent_backend(args.backend): + if args.python_path is not None: + for path in args.python_path.split(os.pathsep): + sys.path.append(path) + + if is_gevent_backend(args.backend) and not args.no_monkey: from gevent import monkey monkey.noisy = False monkey.patch_all() @@ -202,7 +213,8 @@ def main(): graceful_timeout=args.graceful_timeout, logger=logger, address_family=address_family, - socket_type=_SOCKET_TYPE[args.socket_type]) + socket_type=_SOCKET_TYPE[args.socket_type], + disable_monkeypatch=args.no_monkey) try: httpd.serve_forever() except KeyboardInterrupt: diff --git a/chaussette/tests/test_backend.py b/chaussette/tests/test_backend.py index 10f84ae..914e6e7 100644 --- a/chaussette/tests/test_backend.py +++ b/chaussette/tests/test_backend.py @@ -13,7 +13,7 @@ PY2 = ['bjoern', 'eventlet', 'fastgevent', 'gevent', 'socketio', 'tornado', 'waitress', 'wsgiref'] PYPY = ['tornado', 'waitress', 'wsgiref'] -PY3 = ['meinheld', 'tornado', 'waitress', 'wsgiref'] +PY3 = ['eventlet', 'meinheld', 'tornado', 'waitress', 'wsgiref'] class TestBackend(unittest.TestCase): diff --git a/chaussette/tests/test_server.py b/chaussette/tests/test_server.py index 4815089..fa1b3ad 100644 --- a/chaussette/tests/test_server.py +++ b/chaussette/tests/test_server.py @@ -78,6 +78,7 @@ class TestServer(unittest.TestCase): " 'app',", " address_family=2,", " backlog=2048,", + " disable_monkeypatch=False,", "socket_type=1)" ])) self.assertEqual(server, 'backend_impl') @@ -107,19 +108,12 @@ class TestServer(unittest.TestCase): " 'app',", " address_family=2,", " backlog=2048,", + " disable_monkeypatch=False,", " socket_type=1,", " spawn=5)" ])) self.assertEqual(server, 'backend_impl') - def test_make_server_spawn_fail(self): - """ - Check the spawn option for a backend that does not support it - :return: - """ - self.assertRaises(TypeError, chaussette.server.make_server, 'app', - 'host', 'port', spawn=5) - class TestMain(unittest.TestCase): """ @@ -149,19 +143,22 @@ class TestMain(unittest.TestCase): break except socket.error: continue - return proc + return proc, cmd @hush def test_main(self): for backend in backends(): resp = None - server = self._launch(backend) + server, cmd = self._launch(backend) try: # socketio is not a WSGI Server. # So we check only it can be started. if backend == 'socketio': continue - resp = requests.get('http://localhost:8080') + try: + resp = requests.get('http://localhost:8080') + except Exception: + raise Exception(cmd) status = resp.status_code self.assertEqual(status, 200, backend) self.assertEqual(resp.text, u"hello world") diff --git a/docs/source/index.rst b/docs/source/index.rst index f994528..3a4a06b 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -16,13 +16,23 @@ That makes **Chaussette** the best companion to run a WSGI or Django stack under a process and socket manager, such as `Circus <http://circus.rtfd.org>`_ or `Supervisor <http://supervisord.org>`_. -.. image:: https://secure.travis-ci.org/circus-tent/chaussette.png?branch=master +.. image:: https://travis-ci.org/circus-tent/chaussette.svg?branch=master :alt: Build Status :target: https://secure.travis-ci.org/circus-tent/chaussette/ -.. image:: https://coveralls.io/repos/circus-tent/chaussette/badge.png?branch=master + +.. image:: https://coveralls.io/repos/circus-tent/chaussette/badge.svg?branch=master :alt: Coverage Status on master :target: https://coveralls.io/r/circus-tent/chaussette?branch=master +.. image:: https://img.shields.io/pypi/v/chaussette.svg + :target: https://python.org/pypi/chaussette/ + +.. image:: https://img.shields.io/pypi/dm/chaussette.svg + :target: https://python.org/pypi/chaussette/ + +.. image:: http://allmychanges.com/p/python/chaussette/badge/ + :target: http://allmychanges.com/p/python/chaussette/?utm_source=badge + Usage @@ -90,7 +100,7 @@ Using Chaussette in Circus The typical use case is to run Chaussette processes under a process and socket manager. Chaussette was developed to run under `Circus -<http://circus.readthedocs.org>`_, which takes care of binding the +<https://circus.readthedocs.io>`_, which takes care of binding the socket and spawning Chaussette processes. To run your WSGI application using Circus, define a *socket* section in your @@ -237,13 +247,13 @@ Chaussette child processes that accept connections on that socket. For more information about this design, read : - http://blog.ziade.org/2012/06/12/shared-sockets-in-circus. -- http://circus.readthedocs.org/en/latest/for-ops/sockets/ +- https://circus.readthedocs.io/en/latest/for-ops/sockets/ Useful links ============ - Repository : https://github.com/circus-tent/chaussette -- Documentation : https://chaussette.readthedocs.org +- Documentation : https://chaussette.readthedocs.io - Continuous Integration: https://travis-ci.org/circus-tent/chaussette @@ -40,7 +40,7 @@ if sys.version_info[0] == 2: setup(name='chaussette', version=__version__, - url='http://chaussette.readthedocs.org', + url='https://chaussette.readthedocs.io', packages=find_packages(exclude=['examples', 'examples.simple_chat']), description=("A WSGI Server for Circus"), long_description=README, @@ -1,49 +1,26 @@ [tox] -envlist = flake8,py26,py27,py33,py34,docs +envlist = flake8,py27,py35,docs [testenv] +setenv = + TESTING=1 + PYTHONHASHSEED=random commands = - {envbindir}/python -V - {envbindir}/python setup.py test + python -V + nosetests -x chaussette/tests deps = nose - waitress tornado requests minimock meinheld greenlet -[testenv:py26] -deps = - nose - waitress - tornado - requests - minimock - meinheld - greenlet - Paste - PasteDeploy - unittest2 - ws4py - gevent - gevent-websocket - gevent-socketio - eventlet - bjoern - - [testenv:py27] +passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH deps = - nose - waitress - tornado - requests - minimock - meinheld - greenlet + {[testenv]deps} Paste PasteDeploy unittest2 @@ -53,30 +30,24 @@ deps = gevent-socketio eventlet bjoern - -[testenv:py33] -deps = - nose + coverage + coveralls + nose-cov + randomize waitress - tornado - requests - minimock - meinheld - greenlet - ws4py - eventlet +commands = + python -V + nosetests --randomize -x --with-coverage --cover-package=chaussette chaussette/tests + -coverage combine + coverage html + -coveralls -[testenv:py34] +[testenv:py35] deps = - nose - waitress - tornado - requests - minimock - meinheld - greenlet + {[testenv]deps} ws4py eventlet + waitress [testenv:docs] deps = Sphinx |