summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Pipping <sebastian@pipping.org>2019-01-02 13:02:18 +0100
committerSebastian Pipping <sebastian@pipping.org>2019-12-09 23:46:12 +0100
commit3d9a8c1d862a5fbbeb2676c283f5c42917702aa5 (patch)
treeec080eee4bbbd760ea159864bec4473f9544b994
parentccadf88107eb934c500be6526811d39a9b449ceb (diff)
downloadbottle-3d9a8c1d862a5fbbeb2676c283f5c42917702aa5.tar.gz
aiohttp: Move from aiohttp<2 to aiohttp-wsgi
-rwxr-xr-x.github/workflows/install-deps.sh2
-rwxr-xr-xbottle.py21
-rwxr-xr-xtest/travis_setup.sh2
3 files changed, 7 insertions, 18 deletions
diff --git a/.github/workflows/install-deps.sh b/.github/workflows/install-deps.sh
index 225a1d9..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 bjoern gevent "aiohttp<2" 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/bottle.py b/bottle.py
index cc42077..9368c46 100755
--- a/bottle.py
+++ b/bottle.py
@@ -3507,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):
@@ -3518,27 +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,
- loop=self.loop,
- 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
diff --git a/test/travis_setup.sh b/test/travis_setup.sh
index 20527dd..c8d5ab2 100755
--- a/test/travis_setup.sh
+++ b/test/travis_setup.sh
@@ -26,6 +26,6 @@ case ${TRAVIS_PYTHON_VERSION} in
pip install flup fapws3 bjoern gevent diesel
;;
3.6)
- pip install "aiohttp<2" uvloop
+ pip install aiohttp-wsgi uvloop
;;
esac