diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..dfbbda1 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,8 @@ +language: python +python: 3.6 +cache: pip + +install: python3 -m pip install -U pip -r requirements.txt + +script: + - sphinx-build -n -W -q -b html -d _build/doctrees . _build/html diff --git a/conf.py b/conf.py index ba5b257..65ca951 100644 --- a/conf.py +++ b/conf.py @@ -178,7 +178,7 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = ['_build/html/_static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied diff --git a/getting_started.rst b/getting_started.rst index af409a6..dffaa36 100644 --- a/getting_started.rst +++ b/getting_started.rst @@ -23,25 +23,34 @@ All platforms with ``conda`` * Create a new Python 3.5 environment (named ``aio35``, use a different if you like):: + .. highlight:: bash + conda create -n aio35 python=3.5 * Activate it. Linux and OS X:: + .. highlight:: bash + $ source activate aio35 Windows:: + .. highlight:: bash + $ source activate aio35 * Install ``aiohttp``:: + .. highlight:: bash + $(aio35) pip install aiohttp Platform specific ----------------- .. would be good to have some word about installing on Windows + * Windows: The easiest way to use Python 3.5 would be to use a package manager such as conda. See the installation instructions above. * Mac OS X: Install `Homebrew `_ task It represents the execution of a coroutine and take care the result in a - future. More details in `official documentation + future. More details in `official task documentation `_ + diff --git a/hello_world.rst b/hello_world.rst index 6b8500f..cea3f3f 100644 --- a/hello_world.rst +++ b/hello_world.rst @@ -9,11 +9,11 @@ This is a series of examples showing the basics of how to write Simple coroutine ---------------- -This example uses the :py:meth:`asyncio.BaseEventLoop.run_until_complete` +This example uses the :py:meth:`asyncio.AbstractEventLoop.run_until_complete` method to schedule a simple function that will wait one second, print ``hello`` and then finish. -Because it is launched with :py:meth:`run_until_complete`, +Because it is launched with :py:meth:`asyncio.AbstractEventLoop.run_until_complete`, the :term:`event loop ` itself will terminate once the :term:`coroutine ` is completed. @@ -49,7 +49,9 @@ all scheduled :term:`tasks ` could execute, which results in a warning. Warning:: - Task was destroyed but it is pending! - task: - wait_for=> +.. highlight:: none + + Task was destroyed but it is pending! + task: + wait_for=> diff --git a/webscraper.rst b/webscraper.rst index f85fa7a..af59b9f 100644 --- a/webscraper.rst +++ b/webscraper.rst @@ -21,6 +21,8 @@ This is a very simple web server. (See below for the code.) Its only purpose is to wait for a given amount of time. Test it by running it from the command line:: +.. highlight:: bash + $ python simple_server.py It will answer like this:: @@ -125,6 +127,8 @@ difference provides the elapsed run time. Finally, we can run our client:: +.. highlight:: bash + $ python synchronous_client.py and get this output:: @@ -254,6 +258,8 @@ This means, we wait until each pages has been retrieved before asking for the next. Let's run it from the command-line to see what happens:: +.. highlight:: bash + $ async_client_blocking.py It took 11.06 seconds for a total waiting time of 11.00. Waited for 1.00 seconds. @@ -320,6 +326,8 @@ So, for a list with 100 tasks it would mean: Let's see if we got any faster:: +.. highlight:: bash + $ async_client_nonblocking.py It took 5.08 seconds for a total waiting time of 11.00. Waited for 1.00 seconds. @@ -359,6 +367,8 @@ The library aiohttp_ allows to write HTTP client and server applications, using a high-level approach. Install with:: +.. highlight:: bash + $ pip install aiohttp @@ -409,6 +419,8 @@ to ``fetch_page()`` as the first argument. Finally, we run this program:: +.. highlight:: bash + $ python aiohttp_client.py It took 5.04 seconds for a total waiting time of 11.00. Waited for 1.00 seconds.