diff options
author | Marcel Hellkamp <marc@gsites.de> | 2019-12-18 10:37:27 +0100 |
---|---|---|
committer | Marcel Hellkamp <marc@gsites.de> | 2019-12-18 10:37:27 +0100 |
commit | d9903c7508294e10b932099afb1e7f108f9a9022 (patch) | |
tree | 4aa462b7c83846e54077d4bf60f34bdea63b8b54 | |
parent | e3492dba468fdc8bcd582a09340d1a174204268f (diff) | |
parent | db2b7c996babc2a8ce9855462b626ee720686f27 (diff) | |
download | bottle-d9903c7508294e10b932099afb1e7f108f9a9022.tar.gz |
Merge branch 'backend-testing' of https://github.com/hartwork/bottle into master.
This patch-set includes two breaking changes:
* "rocket" server adapter was removed, as it does not support Python 3 and is unmaintained.
It will be marked as deprectated retrospectively in 0.12
* The "aiohttp" server adapter now uses aiohttp-wsgi instead of aiohttp.
It was never part of 0.12 (stable), so changing this should be fine.
-rwxr-xr-x | .github/workflows/install-deps.sh | 2 | ||||
-rw-r--r-- | .travis.yml | 1 | ||||
-rwxr-xr-x | bottle.py | 30 | ||||
-rw-r--r-- | docs/_locale/_pot/deployment.pot | 8 | ||||
-rw-r--r-- | docs/_locale/de_DE/LC_MESSAGES/deployment.po | 8 | ||||
-rw-r--r-- | docs/_locale/pt_BR/LC_MESSAGES/_pot/deployment.po | 8 | ||||
-rw-r--r-- | docs/_locale/pt_BR/LC_MESSAGES/deployment.po | 8 | ||||
-rw-r--r-- | docs/_locale/ru_RU/LC_MESSAGES/deployment.po | 8 | ||||
-rw-r--r-- | docs/_locale/zh_CN/LC_MESSAGES/_pot/deployment.po | 8 | ||||
-rw-r--r-- | docs/_locale/zh_CN/LC_MESSAGES/deployment.po | 8 | ||||
-rw-r--r-- | docs/deployment.rst | 2 | ||||
-rw-r--r-- | test/servertest.py | 63 | ||||
-rw-r--r-- | test/test_server.py | 25 | ||||
-rwxr-xr-x | test/travis_setup.sh | 22 |
14 files changed, 72 insertions, 129 deletions
diff --git a/.github/workflows/install-deps.sh b/.github/workflows/install-deps.sh index 848c24d..283f1bf 100755 --- a/.github/workflows/install-deps.sh +++ b/.github/workflows/install-deps.sh @@ -10,6 +10,6 @@ sudo apt-get install -y libev-dev pip install mako jinja2 for name in waitress "cherrypy<9" cheroot paste tornado twisted diesel meinheld\ - gunicorn eventlet flup fapws3 rocket bjoern gevent uvloop; do + gunicorn eventlet flup fapws3 bjoern gevent aiohttp-wsgi uvloop; do pip install $name || echo "Failed to install $name with $(python -V 2>&1)" 1>&2 done diff --git a/.travis.yml b/.travis.yml index 2c448ea..c15b4b0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,6 @@ sudo: required python: # - "2.7.3" # Ubuntu 12.4LTS (precise) and Debian 7 LTS (wheezy) - "2.7" - - "3.4" - "3.5" - "3.6" - "3.7" @@ -3494,15 +3494,6 @@ class EventletServer(ServerAdapter): wsgi.server(listen(address), handler) -class RocketServer(ServerAdapter): - """ Untested. """ - - def run(self, handler): - from rocket import Rocket - server = Rocket((self.host, self.port), 'wsgi', {'wsgi_app': handler}) - server.start() - - class BjoernServer(ServerAdapter): """ Fast server written in C: https://github.com/jonashaag/bjoern """ @@ -3516,9 +3507,9 @@ class AsyncioServerAdapter(ServerAdapter): pass class AiohttpServer(AsyncioServerAdapter): - """ Untested. - aiohttp + """ Asynchronous HTTP client/server framework for asyncio https://pypi.python.org/pypi/aiohttp/ + https://pypi.org/project/aiohttp-wsgi/ """ def get_event_loop(self): @@ -3527,26 +3518,16 @@ class AiohttpServer(AsyncioServerAdapter): def run(self, handler): import asyncio - from aiohttp.wsgi import WSGIServerHttpProtocol + from aiohttp_wsgi.wsgi import serve self.loop = self.get_event_loop() asyncio.set_event_loop(self.loop) - protocol_factory = lambda: WSGIServerHttpProtocol( - handler, - readpayload=True, - debug=(not self.quiet)) - self.loop.run_until_complete(self.loop.create_server(protocol_factory, - self.host, - self.port)) - if 'BOTTLE_CHILD' in os.environ: import signal signal.signal(signal.SIGINT, lambda s, f: self.loop.stop()) - try: - self.loop.run_forever() - except KeyboardInterrupt: - self.loop.stop() + serve(handler, host=self.host, port=self.port) + class AiohttpUVLoopServer(AiohttpServer): """uvloop @@ -3586,7 +3567,6 @@ server_names = { 'gunicorn': GunicornServer, 'eventlet': EventletServer, 'gevent': GeventServer, - 'rocket': RocketServer, 'bjoern': BjoernServer, 'aiohttp': AiohttpServer, 'uvloop': AiohttpUVLoopServer, diff --git a/docs/_locale/_pot/deployment.pot b/docs/_locale/_pot/deployment.pot index 23f2b23..8ddf019 100644 --- a/docs/_locale/_pot/deployment.pot +++ b/docs/_locale/_pot/deployment.pot @@ -153,14 +153,6 @@ msgid "Multi-threaded, stable, tried and tested" msgstr "" #: ../../deployment.rst:68 -msgid "rocket" -msgstr "" - -#: ../../deployment.rst:68 -msgid "rocket_" -msgstr "" - -#: ../../deployment.rst:68 msgid "Multi-threaded" msgstr "" diff --git a/docs/_locale/de_DE/LC_MESSAGES/deployment.po b/docs/_locale/de_DE/LC_MESSAGES/deployment.po index e8f9d82..81eedfc 100644 --- a/docs/_locale/de_DE/LC_MESSAGES/deployment.po +++ b/docs/_locale/de_DE/LC_MESSAGES/deployment.po @@ -192,14 +192,6 @@ msgid "Multi-threaded, stable, tried and tested" msgstr "" #: ../../deployment.rst:68 -msgid "rocket" -msgstr "" - -#: ../../deployment.rst:68 -msgid "rocket_" -msgstr "" - -#: ../../deployment.rst:68 msgid "Multi-threaded" msgstr "" diff --git a/docs/_locale/pt_BR/LC_MESSAGES/_pot/deployment.po b/docs/_locale/pt_BR/LC_MESSAGES/_pot/deployment.po index 18dce7d..b484cd5 100644 --- a/docs/_locale/pt_BR/LC_MESSAGES/_pot/deployment.po +++ b/docs/_locale/pt_BR/LC_MESSAGES/_pot/deployment.po @@ -186,14 +186,6 @@ msgid "Multi-threaded, stable, tried and tested" msgstr "" #: ../../deployment.rst:68 -msgid "rocket" -msgstr "" - -#: ../../deployment.rst:68 -msgid "rocket_" -msgstr "" - -#: ../../deployment.rst:68 msgid "Multi-threaded" msgstr "" diff --git a/docs/_locale/pt_BR/LC_MESSAGES/deployment.po b/docs/_locale/pt_BR/LC_MESSAGES/deployment.po index f08cc05..d3d027d 100644 --- a/docs/_locale/pt_BR/LC_MESSAGES/deployment.po +++ b/docs/_locale/pt_BR/LC_MESSAGES/deployment.po @@ -192,14 +192,6 @@ msgid "Multi-threaded, stable, tried and tested" msgstr "" #: ../../deployment.rst:68 -msgid "rocket" -msgstr "" - -#: ../../deployment.rst:68 -msgid "rocket_" -msgstr "" - -#: ../../deployment.rst:68 msgid "Multi-threaded" msgstr "" diff --git a/docs/_locale/ru_RU/LC_MESSAGES/deployment.po b/docs/_locale/ru_RU/LC_MESSAGES/deployment.po index 03c8aea..cfb0d3d 100644 --- a/docs/_locale/ru_RU/LC_MESSAGES/deployment.po +++ b/docs/_locale/ru_RU/LC_MESSAGES/deployment.po @@ -192,14 +192,6 @@ msgid "Multi-threaded, stable, tried and tested" msgstr "" #: ../../deployment.rst:68 -msgid "rocket" -msgstr "" - -#: ../../deployment.rst:68 -msgid "rocket_" -msgstr "" - -#: ../../deployment.rst:68 msgid "Multi-threaded" msgstr "" diff --git a/docs/_locale/zh_CN/LC_MESSAGES/_pot/deployment.po b/docs/_locale/zh_CN/LC_MESSAGES/_pot/deployment.po index 18dce7d..b484cd5 100644 --- a/docs/_locale/zh_CN/LC_MESSAGES/_pot/deployment.po +++ b/docs/_locale/zh_CN/LC_MESSAGES/_pot/deployment.po @@ -186,14 +186,6 @@ msgid "Multi-threaded, stable, tried and tested" msgstr "" #: ../../deployment.rst:68 -msgid "rocket" -msgstr "" - -#: ../../deployment.rst:68 -msgid "rocket_" -msgstr "" - -#: ../../deployment.rst:68 msgid "Multi-threaded" msgstr "" diff --git a/docs/_locale/zh_CN/LC_MESSAGES/deployment.po b/docs/_locale/zh_CN/LC_MESSAGES/deployment.po index 6333a0e..5c6de79 100644 --- a/docs/_locale/zh_CN/LC_MESSAGES/deployment.po +++ b/docs/_locale/zh_CN/LC_MESSAGES/deployment.po @@ -192,14 +192,6 @@ msgid "Multi-threaded, stable, tried and tested" msgstr "多线程,稳定,久经考验,充分测试" #: ../../deployment.rst:68 -msgid "rocket" -msgstr "" - -#: ../../deployment.rst:68 -msgid "rocket_" -msgstr "" - -#: ../../deployment.rst:68 msgid "Multi-threaded" msgstr "多线程" diff --git a/docs/deployment.rst b/docs/deployment.rst index 5beafb8..26bb1d6 100644 --- a/docs/deployment.rst +++ b/docs/deployment.rst @@ -3,7 +3,6 @@ .. _wsgiref: http://docs.python.org/library/wsgiref.html .. _cherrypy: http://www.cherrypy.org/ .. _paste: http://pythonpaste.org/ -.. _rocket: http://pypi.python.org/pypi/rocket .. _gunicorn: http://pypi.python.org/pypi/gunicorn .. _fapws3: http://www.fapws.org/ .. _tornado: http://www.tornadoweb.org/ @@ -68,7 +67,6 @@ gae gae_ Helper for Google App Engine deployments wsgiref wsgiref_ Single-threaded default server cherrypy cherrypy_ Multi-threaded and very stable paste paste_ Multi-threaded, stable, tried and tested -rocket rocket_ Multi-threaded waitress waitress_ Multi-threaded, poweres Pyramid gunicorn gunicorn_ Pre-forked, partly written in C eventlet eventlet_ Asynchronous framework with WSGI support. diff --git a/test/servertest.py b/test/servertest.py index c4ac27f..3fd33cc 100644 --- a/test/servertest.py +++ b/test/servertest.py @@ -1,38 +1,39 @@ -if __name__ != '__main__': - raise ImportError('This is not a module, but a script.') +def main(): + import sys, os, socket -import sys, os, socket - -test_root = os.path.dirname(os.path.abspath(__file__)) -os.chdir(test_root) -sys.path.insert(0, os.path.dirname(test_root)) -sys.path.insert(0, test_root) - -try: - server = sys.argv[1] - port = int(sys.argv[2]) - - if server == 'gevent': - from gevent import monkey - monkey.patch_all() - elif server == 'eventlet': - import eventlet - eventlet.monkey_patch() + test_root = os.path.dirname(os.path.abspath(__file__)) + os.chdir(test_root) + sys.path.insert(0, os.path.dirname(test_root)) + sys.path.insert(0, test_root) try: - import coverage - coverage.process_startup() + server = sys.argv[1] + port = int(sys.argv[2]) + + if server == 'gevent': + from gevent import monkey + monkey.patch_all() + elif server == 'eventlet': + import eventlet + eventlet.monkey_patch() + + try: + import coverage + coverage.process_startup() + except ImportError: + pass + + from bottle import route, run + route('/test', callback=lambda: 'OK') + run(port=port, server=server, quiet=True) + + except socket.error: + sys.exit(3) except ImportError: + sys.exit(128) + except KeyboardInterrupt: pass - from bottle import route, run - route('/test', callback=lambda: 'OK') - run(port=port, server=server, quiet=True) - -except socket.error: - sys.exit(3) -except ImportError: - sys.exit(128) -except KeyboardInterrupt: - pass +if __name__ == '__main__': + main() diff --git a/test/test_server.py b/test/test_server.py index 63699ae..0a48e41 100644 --- a/test/test_server.py +++ b/test/test_server.py @@ -54,9 +54,11 @@ class TestServer(unittest.TestCase): if rv is None: raise AssertionError("Server took too long to start up.") if rv is 128: # Import error - tools.warn("Skipping %r test (ImportError)." % self.server) - self.skip = True - return + if os.environ.get('CI') != 'true' or \ + os.environ.get('TRAVIS_PYTHON_VERSION') not in ('2.7', '3.6'): + tools.warn("Skipping %r test (ImportError)." % self.server) + self.skip = True + return if rv is 3: # Port in use continue raise AssertionError("Server exited with error code %d" % rv) @@ -96,7 +98,22 @@ class TestServer(unittest.TestCase): self.assertEqual(tob('OK'), self.fetch('test')) -blacklist = ['cgi', 'flup', 'gae'] +blacklist = ['cgi', 'flup', 'gae', 'wsgiref'] + +if sys.version_info.major == 2: + blacklist += [ + 'aiohttp', + 'uvloop', + ] +else: + blacklist += [ + 'bjoern', + 'diesel', + 'fapws3', + 'flup', + 'gevent', + ] + for name in set(server_names) - set(blacklist): classname = 'TestServerAdapter_'+name diff --git a/test/travis_setup.sh b/test/travis_setup.sh index 3ba2e1a..c8d5ab2 100755 --- a/test/travis_setup.sh +++ b/test/travis_setup.sh @@ -13,15 +13,19 @@ pip install -U coverage pip install coveralls # Server back-ends and template engines. Not all back-ends support all python versions and we only want to test for 2.7 and 3.6 to keep things sane -if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then +case ${TRAVIS_PYTHON_VERSION} in +2.7|3.6) sudo apt-get update -y sudo apt-get install -y libev-dev - pip install mako jinja2 waitress "cherrypy<9" cheroot paste tornado twisted diesel meinheld gunicorn eventlet - pip install flup fapws3 rocket bjoern gevent -elif [[ $TRAVIS_PYTHON_VERSION == 3.6 ]]; then - sudo apt-get update -y - sudo apt-get install -y libev-dev - pip install mako jinja2 waitress "cherrypy<9" cheroot paste tornado twisted diesel meinheld gunicorn eventlet - pip install uvloop -fi + pip install mako jinja2 waitress "cherrypy<9" cheroot paste tornado twisted meinheld gunicorn eventlet + ;; +esac +case ${TRAVIS_PYTHON_VERSION} in +2.7) + pip install flup fapws3 bjoern gevent diesel + ;; +3.6) + pip install aiohttp-wsgi uvloop + ;; +esac |