[Python-modules-commits] [python-aiohttp] 01/04: Import python-aiohttp_0.20.2.orig.tar.gz
Piotr Ożarowski
piotr at moszumanska.debian.org
Thu Jan 28 21:51:36 UTC 2016
This is an automated email from the git hooks/post-receive script.
piotr pushed a commit to branch master
in repository python-aiohttp.
commit 108d779afd8a8f8a6b4657f107a461a82f6d4f05
Author: Piotr Ożarowski <piotr at debian.org>
Date: Thu Jan 28 21:47:34 2016 +0100
Import python-aiohttp_0.20.2.orig.tar.gz
---
CHANGES.txt | 86 +-
CONTRIBUTORS.txt | 28 +-
LICENSE.txt | 2 +-
Makefile | 47 +-
PKG-INFO | 192 +-
README.rst | 136 +-
aiohttp.egg-info/PKG-INFO | 192 +-
aiohttp.egg-info/SOURCES.txt | 40 +-
aiohttp.egg-info/pbr.json | 1 +
aiohttp/__init__.py | 4 +-
aiohttp/_multidict.c | 7994 +++++++++++++-------
aiohttp/_multidict.pyx | 278 +-
aiohttp/_websocket.c | 416 +-
aiohttp/_websocket.pyx | 52 +-
aiohttp/abc.py | 25 +
aiohttp/client.py | 527 +-
aiohttp/client_reqrep.py | 226 +-
aiohttp/connector.py | 139 +-
aiohttp/errors.py | 7 +-
aiohttp/hdrs.py | 4 +
aiohttp/helpers.py | 337 +-
aiohttp/multidict.py | 26 +-
aiohttp/multipart.py | 50 +-
aiohttp/parsers.py | 167 +-
aiohttp/protocol.py | 98 +-
aiohttp/server.py | 95 +-
aiohttp/signals.py | 71 +
aiohttp/streams.py | 188 +-
aiohttp/test_utils.py | 3 -
aiohttp/web.py | 58 +-
aiohttp/web_exceptions.py | 50 +-
aiohttp/web_reqrep.py | 135 +-
aiohttp/web_urldispatcher.py | 196 +-
aiohttp/web_ws.py | 62 +-
aiohttp/websocket.py | 15 +-
aiohttp/websocket_client.py | 62 +-
aiohttp/worker.py | 12 +-
aiohttp/wsgi.py | 60 +-
docs/api.rst | 9 +
docs/client.rst | 493 +-
docs/client_reference.rst | 504 +-
docs/client_websockets.rst | 172 -
docs/conf.py | 9 +-
docs/glossary.rst | 16 +-
docs/gunicorn.rst | 65 +-
docs/index.rst | 64 +-
docs/logging.rst | 93 +
docs/multidict.rst | 51 +-
docs/multipart.rst | 129 +-
docs/python33.rst | 15 +
docs/server.rst | 21 +-
docs/spelling_wordlist.txt | 12 +
docs/web.rst | 642 +-
docs/web_reference.rst | 343 +-
examples/client_json.py | 26 +
examples/srv.py | 2 -
examples/web_classview1.py | 67 +
examples/web_srv.py | 5 +-
examples/web_ws.py | 2 +-
setup.cfg | 2 +-
setup.py | 35 +-
tests/autobahn/server.py | 2 +-
tests/conftest.py | 287 +
tests/test_classbasedview.py | 57 +
tests/test_client_connection.py | 97 +
tests/test_client_functional.py | 1797 +----
tests/test_client_functional_newstyle.py | 121 -
...ional.py => test_client_functional_oldstyle.py} | 93 +-
tests/test_client_request.py | 814 +-
tests/test_client_response.py | 71 +-
tests/test_client_session.py | 717 +-
tests/test_connector.py | 705 +-
tests/test_errors.py | 15 +-
tests/test_helpers.py | 326 +-
tests/test_http_protocol.py | 503 --
tests/test_http_server.py | 550 --
tests/test_multidict.py | 64 +-
tests/test_multipart.py | 2 +-
tests/test_parser_buffer.py | 286 +
tests/test_parsers.py | 597 --
tests/test_protocol.py | 516 ++
tests/test_proxy_connector.py | 422 ++
tests/test_py35/test_cbv35.py | 19 +
tests/test_py35/test_client_websocket_35.py | 74 +
tests/test_py35/test_multipart_35.py | 68 +
tests/test_py35/test_resp.py | 55 +
tests/test_py35/test_streams_35.py | 72 +
tests/test_py35/test_web_websocket_35.py | 36 +
tests/test_server.py | 547 ++
tests/test_signals.py | 145 +
tests/test_stream_parser.py | 354 +
tests/test_stream_protocol.py | 39 +
tests/test_stream_writer.py | 217 +
tests/test_streams.py | 157 +-
tests/test_timeout.py | 148 +
tests/test_urldispatch.py | 110 +
tests/test_web.py | 145 -
tests/test_web_application.py | 84 +
tests/test_web_exceptions.py | 313 +-
tests/test_web_functional.py | 550 +-
tests/test_web_middleware.py | 169 +-
tests/test_web_request.py | 408 +-
tests/test_web_request_handler.py | 65 +
tests/test_web_response.py | 1476 ++--
tests/test_web_websocket.py | 88 +-
tests/test_web_websocket_functional.py | 64 +-
tests/test_websocket.py | 663 --
tests/test_websocket_client.py | 414 +-
tests/test_websocket_client_functional.py | 285 +
tests/test_websocket_handshake.py | 146 +
tests/test_websocket_parser.py | 496 ++
tests/test_websocket_writer.py | 62 +
tests/test_worker.py | 258 +-
tests/test_wsgi.py | 117 +-
114 files changed, 18393 insertions(+), 12351 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index 56746d4..84d44de 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,87 +1,11 @@
CHANGES
=======
-0.17.4 (09-29-2015)
--------------------
+0.20.2 (01-07-2015)
+--------------------
-- Properly parse URL path in aiohttp.web.Request #489
+- Enable use of `await` for a class based view #717
-- Add missing coroutine decorator, the client api is await-compatible now
-
-0.17.3 (08-28-2015)
----------------------
-
-- Remove Content-Length header on compressed responses #450
-
-- Support Python 3.5
-
-- Improve performance of transport in-use list #472
-
-- Fix connection pooling #473
-
-0.17.2 (08-11-2015)
----------------------
-
-- Don't forget to pass `data` argument forward #462
-
-- Fix multipart read bytes count #463
-
-0.17.1 (08-10-2015)
----------------------
-
-- Fix multidict comparsion to arbitrary abc.Mapping
-
-0.17.0 (08-04-2015)
----------------------
-
-- Make StaticRoute support Last-Modified and If-Modified-Since headers #386
-
-- Add Request.if_modified_since and Stream.Response.last_modified properties
-
-- Fix deflate compression when writing a chunked response #395
-
-- Request`s content-length header is cleared now after redirect from
- POST method #391
-
-- Return a 400 if server received a non HTTP content #405
-
-- Fix keep-alive support for aiohttp clients #406
-
-- Allow gzip compression in high-level server response interface #403
-
-- Rename TCPConnector.resolve and family to dns_cache #415
-
-- Make UrlDispatcher ignore quoted characters during url matching #414
- Backward-compatibility warning: this may change the url matched by
- your queries if they send quoted character (like %2F for /) #414
-
-- Use optional cchardet accelerator if present #418
-
-- Borrow loop from Connector in ClientSession if loop is not set
-
-- Add context manager support to ClientSession for session closing.
-
-- Add toplevel get(), post(), put(), head(), delete(), options(),
- patch() coroutines.
-
-- Fix IPv6 support for client API #425
-
-- Pass SSL context through proxy connector #421
-
-- Make the rule: path for add_route should start with slash
-
-- Don't process request finishing by low-level server on closed event loop
-
-- Don't override data if multiple files are uploaded with same key #433
-
-- Ensure multipart.BodyPartReader.read_chunk read all the necessary data
- to avoid false assertions about malformed multipart payload
-
-- Dont sent body for 204, 205 and 304 http exceptions #442
-
-- Correctly skip Cython compilation in MSVC not found #453
-
-- Add response factory to StaticRoute #456
-
-- Don't append trailing CRLF for multipart.BodyPartReader #454
+- Check address family to fill wsgi env properly #718
+- Fix memory leak in headers processing (thanks to Marco Paolini) #723
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt
index 992bdf6..b6d680e 100644
--- a/CONTRIBUTORS.txt
+++ b/CONTRIBUTORS.txt
@@ -3,8 +3,11 @@ Contributors
A. Jesse Jiryu Davis
Alejandro Gómez
+Alex Khomchenko
Alex Lisovoy
Alexander Bayandin
+Alexander Karpinsky
+Alexander Malev
Alexander Shorin
Alexander Travov
Alexey Popravka
@@ -17,7 +20,11 @@ Ben Bader
Benedikt Reinartz
Brian C. Lane
Boris Feld
+Carl George
+Chien-Wei Huang
+Chih-Yuan Chen
Chris Laws
+Chris Moore
Daniel Nelson
David Michael Brown
Dima Veselov
@@ -34,18 +41,28 @@ Greg Holt
Hugo Herter
Igor Pavlov
Ingmar Steen
+Jaesung Lee
+Jashandeep Sohi
+Jeroen van der Heijden
+Jesus Cea
+Joel Watts
Julien Duponchelle
Junjie Tao
Kay Zheng
Kirill Klenov
Kirill Malovitsa
+Kyrylo Perevozchikov
+Lars P. Søndergaard
Ludovic Gasc
Lukasz Marcin Dobrzanski
Marco Paolini
Martin Richard
+Mathias Fröjdman
+Matthieu Hauglustaine
+Michael Ihnatenko
+Mikhail Lukyanchenko
Morgan Delahaye-Prat
Moss Collum
-Mikhail Lukyanchenko
Nicolas Braem
Nikolay Novik
Olaf Conradi
@@ -58,14 +75,23 @@ Robert Lu
Sebastian Hanula
Sebastian Hüther
Sergey Ninua
+Sergey Skripnick
Simon Kennedy
+Stanislas Plum
Stanislav Prokop
Stephen Granade
+Sviatoslav Bulbakha
Taras Voinarovskyi
Tolga Tezel
+Thomas Grainger
Vaibhav Sagar
+Vasyl Baran
+Vitalik Verhovodov
Vitaly Haritonsky
Vitaly Magerya
+Vladimir Rutsky
+Vladimir Shulyak
Vladimir Zakharov
W. Trevor King
Yannick Koechlin
+Коренберг Марк
diff --git a/LICENSE.txt b/LICENSE.txt
index 20e3c05..8d46cf7 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -186,7 +186,7 @@ Apache License
same "printed page" as the copyright notice for easier
identification within third-party archives.
- Copyright 2013, 2014, 2015 Nikolay Kim and Andrew Svetlov
+ Copyright 2013-2016 Nikolay Kim and Andrew Svetlov
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/Makefile b/Makefile
index 6ae2e45..3ece965 100644
--- a/Makefile
+++ b/Makefile
@@ -1,33 +1,38 @@
# Some simple testing tasks (sorry, UNIX only).
-FLAGS=
+.install-deps: requirements-dev.txt
+ pip install -U -r requirements-dev.txt
+ touch .install-deps
-
-flake:
+flake: .install-deps
# python setup.py check -rms
- flake8 aiohttp tests examples
+ flake8 aiohttp
+ if python -c "import sys; sys.exit(sys.version_info < (3,5))"; then \
+ flake8 examples tests; \
+ fi
+
-develop:
- python setup.py develop
+.develop: .install-deps $(shell find aiohttp -type f)
+ pip install -e .
+ touch .develop
-test: flake develop
- nosetests -s $(FLAGS) ./tests/
+test: flake .develop
+ py.test -q ./tests/
-vtest: flake develop
- nosetests -s -v $(FLAGS) ./tests/
+vtest: flake .develop
+ py.test -s -v ./tests/
cov cover coverage:
tox
-cov-dev: flake develop
- @coverage erase
- @coverage run -m nose -s $(FLAGS) tests
- @mv .coverage .coverage.accel
- @AIOHTTP_NO_EXTENSIONS=1 coverage run -m nose -s $(FLAGS) tests
- @mv .coverage .coverage.pure
- @coverage combine
- @coverage report
- @coverage html
+cov-dev: .develop
+ py.test --cov=aiohttp --cov-report=term --cov-report=html tests
+ @echo "open file://`pwd`/coverage/index.html"
+
+cov-dev-full: .develop
+ AIOHTTP_NO_EXTENSIONS=1 py.test --cov=aiohttp --cov-append tests
+ PYTHONASYNCIODEBUG=1 py.test --cov=aiohttp --cov-append tests
+ py.test --cov=aiohttp --cov-report=term --cov-report=html tests
@echo "open file://`pwd`/coverage/index.html"
clean:
@@ -58,4 +63,8 @@ doc:
doc-spelling:
make -C docs spelling
+install:
+ pip install -U pip
+ pip install -Ur requirements-dev.txt
+
.PHONY: all build venv flake test vtest testloop cov clean doc
diff --git a/PKG-INFO b/PKG-INFO
index 4928f7d..f3e2d0e 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,10 +1,10 @@
Metadata-Version: 1.1
Name: aiohttp
-Version: 0.17.4
+Version: 0.20.2
Summary: http client/server for asyncio
Home-page: https://github.com/KeepSafe/aiohttp/
-Author: Nikolay Kim
-Author-email: fafhrd91 at gmail.com
+Author: Andrew Svetlov
+Author-email: andrew.svetlov at gmail.com
License: Apache 2
Description: http client/server for asyncio
==============================
@@ -14,10 +14,17 @@ Description: http client/server for asyncio
:width: 64px
:alt: aiohttp logo
- .. image:: https://secure.travis-ci.org/KeepSafe/aiohttp.png
- :target: https://secure.travis-ci.org/KeepSafe/aiohttp
+ .. image:: https://travis-ci.org/KeepSafe/aiohttp.svg?branch=master
+ :target: https://travis-ci.org/KeepSafe/aiohttp
:align: right
+ .. image:: https://coveralls.io/repos/KeepSafe/aiohttp/badge.svg?branch=master&service=github
+ :target: https://coveralls.io/github/KeepSafe/aiohttp?branch=master
+ :align: right
+
+ .. image:: https://badge.fury.io/py/aiohttp.svg
+ :target: https://badge.fury.io/py/aiohttp
+
Features
--------
@@ -26,36 +33,6 @@ Description: http client/server for asyncio
- Web-server has middlewares and pluggable routing.
- Requirements
- ------------
-
- - Python >= 3.3
- - asyncio https://pypi.python.org/pypi/asyncio
-
-
- License
- -------
-
- ``aiohttp`` is offered under the Apache 2 license.
-
-
- Documentation
- -------------
-
- http://aiohttp.readthedocs.org/
-
- Source code
- ------------
-
- The latest developer version is available in a github repository:
- https://github.com/KeepSafe/aiohttp
-
- Benchmarks
- ----------
-
- If you are interested in by efficiency, AsyncIO community maintains a list of benchmarks on the official wiki:
- https://github.com/python/asyncio/wiki/Benchmarks
-
Getting started
---------------
@@ -69,31 +46,24 @@ Description: http client/server for asyncio
import aiohttp
import asyncio
- def get_body(url):
- response = yield from aiohttp.request('GET', url)
- return (yield from response.read())
+ async def get_body(client, url):
+ async with client.get(url) as response:
+ return await response.read()
if __name__ == '__main__':
loop = asyncio.get_event_loop()
- raw_html = loop.run_until_complete(get_body('http://python.org'))
+ client = aiohttp.ClientSession(loop=loop)
+ raw_html = loop.run_until_complete(get_body(client, 'http://python.org'))
print(raw_html)
+ client.close()
- You can use the get command like this anywhere in your ``asyncio``
- powered program:
-
- .. code-block:: python
-
- response = yield from aiohttp.request('GET', 'http://python.org')
- body = yield from response.read()
- print(body)
-
- If you want to use timeouts for aiohttp client side please use standard
+ If you want to use timeouts for aiohttp client please use standard
asyncio approach:
.. code-block:: python
- yield from asyncio.wait_for(request('GET', url), 10)
+ yield from asyncio.wait_for(client.get(url), 10)
Server
@@ -106,22 +76,16 @@ Description: http client/server for asyncio
import asyncio
from aiohttp import web
-
- @asyncio.coroutine
- def handle(request):
+ async def handle(request):
name = request.match_info.get('name', "Anonymous")
text = "Hello, " + name
return web.Response(body=text.encode('utf-8'))
-
- @asyncio.coroutine
- def wshandler(request):
+ async def wshandler(request):
ws = web.WebSocketResponse()
- ws.start(request)
-
- while True:
- msg = yield from ws.receive()
+ await ws.prepare(request)
+ async for msg in ws:
if msg.tp == web.MsgType.text:
ws.send_str("Hello, {}".format(msg.data))
elif msg.tp == web.MsgType.binary:
@@ -132,13 +96,12 @@ Description: http client/server for asyncio
return ws
- @asyncio.coroutine
- def init(loop):
+ async def init(loop):
app = web.Application(loop=loop)
app.router.add_route('GET', '/echo', wshandler)
app.router.add_route('GET', '/{name}', handle)
- srv = yield from loop.create_server(app.make_handler(),
+ srv = await loop.create_server(app.make_handler(),
'127.0.0.1', 8080)
print("Server started at http://127.0.0.1:8080")
return srv
@@ -147,98 +110,75 @@ Description: http client/server for asyncio
loop.run_until_complete(init(loop))
loop.run_forever()
- CHANGES
- =======
-
- 0.17.4 (09-29-2015)
- -------------------
-
- - Properly parse URL path in aiohttp.web.Request #489
-
- - Add missing coroutine decorator, the client api is await-compatible now
-
- 0.17.3 (08-28-2015)
- ---------------------
-
- - Remove Content-Length header on compressed responses #450
- - Support Python 3.5
+ Note: examples are written for Python 3.5+ and utilize PEP-492 aka
+ async/await. If you are using Python 3.4 please replace ``await`` with
+ ``yield from`` and ``async def`` with ``@coroutine`` e.g.::
- - Improve performance of transport in-use list #472
+ async def coro(...):
+ ret = await f()
- - Fix connection pooling #473
+ shoud be replaced by::
- 0.17.2 (08-11-2015)
- ---------------------
-
- - Don't forget to pass `data` argument forward #462
-
- - Fix multipart read bytes count #463
-
- 0.17.1 (08-10-2015)
- ---------------------
-
- - Fix multidict comparsion to arbitrary abc.Mapping
-
- 0.17.0 (08-04-2015)
- ---------------------
-
- - Make StaticRoute support Last-Modified and If-Modified-Since headers #386
-
- - Add Request.if_modified_since and Stream.Response.last_modified properties
-
- - Fix deflate compression when writing a chunked response #395
+ @asyncio.coroutine
+ def coro(...):
+ ret = yield from f()
- - Request`s content-length header is cleared now after redirect from
- POST method #391
+ Documentation
+ -------------
- - Return a 400 if server received a non HTTP content #405
+ http://aiohttp.readthedocs.org/
- - Fix keep-alive support for aiohttp clients #406
+ Discussion list
+ ---------------
- - Allow gzip compression in high-level server response interface #403
+ *aio-libs* google group: https://groups.google.com/forum/#!forum/aio-libs
- - Rename TCPConnector.resolve and family to dns_cache #415
+ Requirements
+ ------------
- - Make UrlDispatcher ignore quoted characters during url matching #414
- Backward-compatibility warning: this may change the url matched by
- your queries if they send quoted character (like %2F for /) #414
+ - Python >= 3.4.1
+ - chardet https://pypi.python.org/pypi/chardet
- - Use optional cchardet accelerator if present #418
+ Optionally you may install cChardet library:
+ https://pypi.python.org/pypi/cchardet/1.0.0
- - Borrow loop from Connector in ClientSession if loop is not set
- - Add context manager support to ClientSession for session closing.
+ License
+ -------
- - Add toplevel get(), post(), put(), head(), delete(), options(),
- patch() coroutines.
+ ``aiohttp`` is offered under the Apache 2 license.
- - Fix IPv6 support for client API #425
- - Pass SSL context through proxy connector #421
+ Source code
+ ------------
- - Make the rule: path for add_route should start with slash
+ The latest developer version is available in a github repository:
+ https://github.com/KeepSafe/aiohttp
- - Don't process request finishing by low-level server on closed event loop
+ Benchmarks
+ ----------
- - Don't override data if multiple files are uploaded with same key #433
+ If you are interested in by efficiency, AsyncIO community maintains a
+ list of benchmarks on the official wiki:
+ https://github.com/python/asyncio/wiki/Benchmarks
- - Ensure multipart.BodyPartReader.read_chunk read all the necessary data
- to avoid false assertions about malformed multipart payload
+ CHANGES
+ =======
- - Dont sent body for 204, 205 and 304 http exceptions #442
+ 0.20.2 (01-07-2015)
+ --------------------
- - Correctly skip Cython compilation in MSVC not found #453
+ - Enable use of `await` for a class based view #717
- - Add response factory to StaticRoute #456
+ - Check address family to fill wsgi env properly #718
- - Don't append trailing CRLF for multipart.BodyPartReader #454
+ - Fix memory leak in headers processing (thanks to Marco Paolini) #723
Platform: UNKNOWN
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Topic :: Internet :: WWW/HTTP
diff --git a/README.rst b/README.rst
index e2e5ff4..9ecf9e6 100644
--- a/README.rst
+++ b/README.rst
@@ -6,10 +6,17 @@ http client/server for asyncio
:width: 64px
:alt: aiohttp logo
-.. image:: https://secure.travis-ci.org/KeepSafe/aiohttp.png
- :target: https://secure.travis-ci.org/KeepSafe/aiohttp
+.. image:: https://travis-ci.org/KeepSafe/aiohttp.svg?branch=master
+ :target: https://travis-ci.org/KeepSafe/aiohttp
:align: right
+.. image:: https://coveralls.io/repos/KeepSafe/aiohttp/badge.svg?branch=master&service=github
+ :target: https://coveralls.io/github/KeepSafe/aiohttp?branch=master
+ :align: right
+
+.. image:: https://badge.fury.io/py/aiohttp.svg
+ :target: https://badge.fury.io/py/aiohttp
+
Features
--------
@@ -18,36 +25,6 @@ Features
- Web-server has middlewares and pluggable routing.
-Requirements
-------------
-
-- Python >= 3.3
-- asyncio https://pypi.python.org/pypi/asyncio
-
-
-License
--------
-
-``aiohttp`` is offered under the Apache 2 license.
-
-
-Documentation
--------------
-
-http://aiohttp.readthedocs.org/
-
-Source code
-------------
-
-The latest developer version is available in a github repository:
-https://github.com/KeepSafe/aiohttp
-
-Benchmarks
-----------
-
-If you are interested in by efficiency, AsyncIO community maintains a list of benchmarks on the official wiki:
-https://github.com/python/asyncio/wiki/Benchmarks
-
Getting started
---------------
@@ -61,31 +38,24 @@ To retrieve something from the web:
import aiohttp
import asyncio
- def get_body(url):
- response = yield from aiohttp.request('GET', url)
- return (yield from response.read())
+ async def get_body(client, url):
+ async with client.get(url) as response:
+ return await response.read()
if __name__ == '__main__':
loop = asyncio.get_event_loop()
- raw_html = loop.run_until_complete(get_body('http://python.org'))
+ client = aiohttp.ClientSession(loop=loop)
+ raw_html = loop.run_until_complete(get_body(client, 'http://python.org'))
print(raw_html)
+ client.close()
-You can use the get command like this anywhere in your ``asyncio``
-powered program:
-
-.. code-block:: python
-
- response = yield from aiohttp.request('GET', 'http://python.org')
- body = yield from response.read()
- print(body)
-
-If you want to use timeouts for aiohttp client side please use standard
+If you want to use timeouts for aiohttp client please use standard
asyncio approach:
.. code-block:: python
- yield from asyncio.wait_for(request('GET', url), 10)
+ yield from asyncio.wait_for(client.get(url), 10)
Server
@@ -98,22 +68,16 @@ This is simple usage example:
import asyncio
from aiohttp import web
-
- @asyncio.coroutine
- def handle(request):
+ async def handle(request):
name = request.match_info.get('name', "Anonymous")
text = "Hello, " + name
return web.Response(body=text.encode('utf-8'))
-
- @asyncio.coroutine
- def wshandler(request):
+ async def wshandler(request):
ws = web.WebSocketResponse()
- ws.start(request)
-
- while True:
- msg = yield from ws.receive()
+ await ws.prepare(request)
+ async for msg in ws:
if msg.tp == web.MsgType.text:
ws.send_str("Hello, {}".format(msg.data))
elif msg.tp == web.MsgType.binary:
@@ -124,13 +88,12 @@ This is simple usage example:
return ws
- @asyncio.coroutine
- def init(loop):
+ async def init(loop):
app = web.Application(loop=loop)
app.router.add_route('GET', '/echo', wshandler)
app.router.add_route('GET', '/{name}', handle)
- srv = yield from loop.create_server(app.make_handler(),
+ srv = await loop.create_server(app.make_handler(),
'127.0.0.1', 8080)
print("Server started at http://127.0.0.1:8080")
return srv
@@ -138,3 +101,56 @@ This is simple usage example:
loop = asyncio.get_event_loop()
loop.run_until_complete(init(loop))
loop.run_forever()
+
+
+Note: examples are written for Python 3.5+ and utilize PEP-492 aka
+async/await. If you are using Python 3.4 please replace ``await`` with
+``yield from`` and ``async def`` with ``@coroutine`` e.g.::
+
+ async def coro(...):
+ ret = await f()
+
+shoud be replaced by::
+
+ @asyncio.coroutine
+ def coro(...):
+ ret = yield from f()
+
+Documentation
+-------------
+
+http://aiohttp.readthedocs.org/
+
+Discussion list
+---------------
+
+*aio-libs* google group: https://groups.google.com/forum/#!forum/aio-libs
+
+Requirements
+------------
+
+- Python >= 3.4.1
+- chardet https://pypi.python.org/pypi/chardet
+
+Optionally you may install cChardet library:
+https://pypi.python.org/pypi/cchardet/1.0.0
+
+
+License
+-------
+
+``aiohttp`` is offered under the Apache 2 license.
+
+
+Source code
+------------
+
+The latest developer version is available in a github repository:
+https://github.com/KeepSafe/aiohttp
+
+Benchmarks
+----------
+
+If you are interested in by efficiency, AsyncIO community maintains a
+list of benchmarks on the official wiki:
+https://github.com/python/asyncio/wiki/Benchmarks
diff --git a/aiohttp.egg-info/PKG-INFO b/aiohttp.egg-info/PKG-INFO
index 4928f7d..f3e2d0e 100644
--- a/aiohttp.egg-info/PKG-INFO
+++ b/aiohttp.egg-info/PKG-INFO
@@ -1,10 +1,10 @@
Metadata-Version: 1.1
Name: aiohttp
-Version: 0.17.4
+Version: 0.20.2
Summary: http client/server for asyncio
Home-page: https://github.com/KeepSafe/aiohttp/
-Author: Nikolay Kim
-Author-email: fafhrd91 at gmail.com
+Author: Andrew Svetlov
+Author-email: andrew.svetlov at gmail.com
License: Apache 2
Description: http client/server for asyncio
==============================
@@ -14,10 +14,17 @@ Description: http client/server for asyncio
:width: 64px
:alt: aiohttp logo
- .. image:: https://secure.travis-ci.org/KeepSafe/aiohttp.png
- :target: https://secure.travis-ci.org/KeepSafe/aiohttp
+ .. image:: https://travis-ci.org/KeepSafe/aiohttp.svg?branch=master
+ :target: https://travis-ci.org/KeepSafe/aiohttp
:align: right
+ .. image:: https://coveralls.io/repos/KeepSafe/aiohttp/badge.svg?branch=master&service=github
+ :target: https://coveralls.io/github/KeepSafe/aiohttp?branch=master
+ :align: right
+
+ .. image:: https://badge.fury.io/py/aiohttp.svg
+ :target: https://badge.fury.io/py/aiohttp
+
Features
--------
@@ -26,36 +33,6 @@ Description: http client/server for asyncio
- Web-server has middlewares and pluggable routing.
- Requirements
- ------------
-
- - Python >= 3.3
- - asyncio https://pypi.python.org/pypi/asyncio
-
-
- License
- -------
-
- ``aiohttp`` is offered under the Apache 2 license.
-
-
- Documentation
- -------------
-
- http://aiohttp.readthedocs.org/
-
- Source code
- ------------
-
- The latest developer version is available in a github repository:
- https://github.com/KeepSafe/aiohttp
-
- Benchmarks
- ----------
-
- If you are interested in by efficiency, AsyncIO community maintains a list of benchmarks on the official wiki:
- https://github.com/python/asyncio/wiki/Benchmarks
-
Getting started
---------------
@@ -69,31 +46,24 @@ Description: http client/server for asyncio
import aiohttp
import asyncio
- def get_body(url):
- response = yield from aiohttp.request('GET', url)
- return (yield from response.read())
+ async def get_body(client, url):
+ async with client.get(url) as response:
+ return await response.read()
if __name__ == '__main__':
loop = asyncio.get_event_loop()
- raw_html = loop.run_until_complete(get_body('http://python.org'))
+ client = aiohttp.ClientSession(loop=loop)
+ raw_html = loop.run_until_complete(get_body(client, 'http://python.org'))
print(raw_html)
+ client.close()
- You can use the get command like this anywhere in your ``asyncio``
- powered program:
-
- .. code-block:: python
-
- response = yield from aiohttp.request('GET', 'http://python.org')
- body = yield from response.read()
- print(body)
-
- If you want to use timeouts for aiohttp client side please use standard
+ If you want to use timeouts for aiohttp client please use standard
asyncio approach:
.. code-block:: python
- yield from asyncio.wait_for(request('GET', url), 10)
+ yield from asyncio.wait_for(client.get(url), 10)
Server
@@ -106,22 +76,16 @@ Description: http client/server for asyncio
import asyncio
... 42255 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-aiohttp.git
More information about the Python-modules-commits
mailing list