[Python-modules-commits] [uvloop] 01/03: import uvloop_0.6.7+ds1.orig.tar.gz

Piotr Ożarowski piotr at moszumanska.debian.org
Fri Dec 23 13:40:17 UTC 2016


This is an automated email from the git hooks/post-receive script.

piotr pushed a commit to branch master
in repository uvloop.

commit d541b94e848281102843e1d3f79f820c3e3d90d0
Author: Piotr Ożarowski <ozarow at gmail.com>
Date:   Fri Dec 23 14:29:31 2016 +0100

    import uvloop_0.6.7+ds1.orig.tar.gz
---
 LICENSE-APACHE                       |    189 +
 LICENSE-MIT                          |     21 +
 MANIFEST.in                          |      9 +
 Makefile                             |     47 +
 PKG-INFO                             |     18 +
 README.rst                           |     83 +
 docs/api/index.rst                   |     20 +
 docs/conf.py                         |     84 +
 docs/dev/index.rst                   |    124 +
 docs/index.rst                       |     63 +
 docs/user/index.rst                  |     40 +
 examples/bench/echoclient.py         |     82 +
 examples/bench/echoserver.py         |    159 +
 examples/bench/rlserver.py           |     94 +
 performance.png                      |    Bin 0 -> 26253 bytes
 setup.cfg                            |      5 +
 setup.py                             |    301 +
 tests/certs/ssl_cert.pem             |     15 +
 tests/certs/ssl_key.pem              |     16 +
 tests/test_aiohttp.py                |     62 +
 tests/test_base.py                   |    583 +
 tests/test_cython.py                 |     27 +
 tests/test_dns.py                    |    179 +
 tests/test_executors.py              |     41 +
 tests/test_futures.py                |    476 +
 tests/test_pipes.py                  |    251 +
 tests/test_process.py                |    638 +
 tests/test_signals.py                |    282 +
 tests/test_sockets.py                |    143 +
 tests/test_tasks.py                  |    427 +
 tests/test_tcp.py                    |   1046 +
 tests/test_testbase.py               |     51 +
 tests/test_udp.py                    |    145 +
 tests/test_unix.py                   |    583 +
 uvloop.egg-info/PKG-INFO             |     18 +
 uvloop.egg-info/SOURCES.txt          |    405 +
 uvloop.egg-info/dependency_links.txt |      1 +
 uvloop.egg-info/top_level.txt        |      1 +
 uvloop/__init__.py                   |     35 +
 uvloop/_noop.py                      |      3 +
 uvloop/_patch.py                     |     70 +
 uvloop/_testbase.py                  |    458 +
 uvloop/cbhandles.pxd                 |     31 +
 uvloop/cbhandles.pyx                 |    312 +
 uvloop/chain_futs.pyx                |    106 +
 uvloop/dns.pyx                       |    359 +
 uvloop/errors.pyx                    |    113 +
 uvloop/future.pyx                    |    485 +
 uvloop/handles/async_.pxd            |     11 +
 uvloop/handles/async_.pyx            |     55 +
 uvloop/handles/basetransport.pxd     |     53 +
 uvloop/handles/basetransport.pyx     |    307 +
 uvloop/handles/check.pxd             |     14 +
 uvloop/handles/check.pyx             |     71 +
 uvloop/handles/handle.pxd            |     43 +
 uvloop/handles/handle.pyx            |    357 +
 uvloop/handles/idle.pxd              |     14 +
 uvloop/handles/idle.pyx              |     71 +
 uvloop/handles/pipe.pxd              |     30 +
 uvloop/handles/pipe.pyx              |    214 +
 uvloop/handles/poll.pxd              |     22 +
 uvloop/handles/poll.pyx              |    225 +
 uvloop/handles/process.pxd           |     78 +
 uvloop/handles/process.pyx           |    712 +
 uvloop/handles/stream.pxd            |     35 +
 uvloop/handles/stream.pyx            |    852 +
 uvloop/handles/streamserver.pxd      |     18 +
 uvloop/handles/streamserver.pyx      |    128 +
 uvloop/handles/tcp.pxd               |     21 +
 uvloop/handles/tcp.pyx               |    214 +
 uvloop/handles/timer.pxd             |     16 +
 uvloop/handles/timer.pyx             |     82 +
 uvloop/handles/udp.pxd               |     25 +
 uvloop/handles/udp.pyx               |    370 +
 uvloop/includes/__init__.py          |     20 +
 uvloop/includes/compat.h             |     29 +
 uvloop/includes/consts.pxi           |     12 +
 uvloop/includes/debug.h              |      3 +
 uvloop/includes/debug.pxd            |      3 +
 uvloop/includes/python.pxd           |     13 +
 uvloop/includes/stdlib.pxi           |    135 +
 uvloop/includes/system.pxd           |     74 +
 uvloop/includes/uv.pxd               |    476 +
 uvloop/loop.c                        | 135752 ++++++++++++++++++++++++++++++++
 uvloop/loop.pxd                      |    204 +
 uvloop/loop.pyx                      |   2580 +
 uvloop/request.pxd                   |      8 +
 uvloop/request.pyx                   |     74 +
 uvloop/server.pxd                    |     12 +
 uvloop/server.pyx                    |     64 +
 90 files changed, 152198 insertions(+)

diff --git a/LICENSE-APACHE b/LICENSE-APACHE
new file mode 100644
index 0000000..b42cbb8
--- /dev/null
+++ b/LICENSE-APACHE
@@ -0,0 +1,189 @@
+   Copyright (c) 2015-present MagicStack Inc.  http://magic.io
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
diff --git a/LICENSE-MIT b/LICENSE-MIT
new file mode 100644
index 0000000..e6b42c6
--- /dev/null
+++ b/LICENSE-MIT
@@ -0,0 +1,21 @@
+The MIT License
+
+Copyright (c) 2015-present MagicStack Inc.  http://magic.io
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..ffc8812
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,9 @@
+recursive-include docs *.py *.rst
+recursive-include examples *.py
+recursive-include tests *.py *.pem
+recursive-include uvloop *.pyx *.pxd *.pxi *.py *.c *.h
+recursive-include vendor/libuv *
+recursive-exclude vendor/libuv/.git *
+recursive-exclude vendor/libuv/docs *
+recursive-exclude vendor/libuv/img *
+include LICENSE-MIT LICENSE-APACHE README.rst Makefile performance.png
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..669b254
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,47 @@
+.PHONY: _default clean clean-libuv distclean compile debug docs test release
+
+
+PYTHON ?= python
+
+
+_default: compile
+
+
+clean:
+	rm -fr dist/ doc/_build/ *.egg-info build/ uvloop/loop.*.pyd
+	rm -fr build/lib.* build/temp.*
+	rm -fr uvloop/*.c uvloop/*.html uvloop/*.so
+	rm -fr uvloop/handles/*.html uvloop/includes/*.html
+	find . -name '__pycache__' | xargs rm -rf
+
+
+clean-libuv:
+	(cd vendor/libuv; git clean -dfX)
+
+
+distclean: clean clean-libuv
+
+
+compile: clean
+	$(PYTHON) setup.py build_ext --inplace --cython-always
+
+
+debug: clean
+	$(PYTHON) setup.py build_ext --inplace --debug \
+		--cython-always \
+		--cython-annotate \
+		--cython-directives="linetrace=True" \
+		--define UVLOOP_DEBUG,CYTHON_TRACE,CYTHON_TRACE_NOGIL
+
+
+docs: compile
+	cd docs && $(PYTHON) -m sphinx -a -b html . _build/html
+
+
+test:
+	PYTHONASYNCIODEBUG=1 $(PYTHON) -m unittest discover -s tests
+	$(PYTHON) -m unittest discover -s tests
+
+
+release: distclean compile test
+	$(PYTHON) setup.py sdist bdist_wheel upload
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..d03a999
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,18 @@
+Metadata-Version: 1.1
+Name: uvloop
+Version: 0.6.7
+Summary: Fast implementation of asyncio event loop on top of libuv
+Home-page: http://github.com/MagicStack/uvloop
+Author: Yury Selivanov
+Author-email: yury at magic.io
+License: MIT
+Description: UNKNOWN
+Platform: *nix
+Classifier: Development Status :: 4 - Beta
+Classifier: Programming Language :: Python :: 3 :: Only
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
+Classifier: License :: OSI Approved :: Apache Software License
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Intended Audience :: Developers
+Provides: uvloop
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..eee0068
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,83 @@
+.. image:: https://travis-ci.org/MagicStack/uvloop.svg?branch=master
+    :target: https://travis-ci.org/MagicStack/uvloop
+
+.. image:: https://img.shields.io/pypi/v/uvloop.svg
+    :target: https://pypi.python.org/pypi/uvloop
+
+
+uvloop is a fast, drop-in replacement of the built-in asyncio
+event loop.  uvloop is implemented in Cython and uses libuv
+under the hood.
+
+The project documentation can be found
+`here <http://uvloop.readthedocs.org/>`_.  Please also check out the
+`wiki <https://github.com/MagicStack/uvloop/wiki>`_.
+
+
+Performance
+-----------
+
+uvloop makes asyncio 2-4x faster.
+
+.. image:: performance.png
+    :target: http://magic.io/blog/uvloop-blazing-fast-python-networking/
+
+The above chart shows the performance of an echo server with different
+message sizes.  The *sockets* benchmark uses ``loop.sock_recv()`` and
+``loop.sock_sendall()`` methods; the *streams* benchmark uses asyncio
+high-level streams, created by the ``asyncio.start_server()`` function;
+and the *protocol* benchmark uses ``loop.create_server()`` with a simple
+echo protocol.  Read more about uvloop
+`performance <http://magic.io/blog/uvloop-blazing-fast-python-networking/>`_.
+
+
+Installation
+------------
+
+uvloop requires Python 3.5 and is available on PyPI.
+Use pip to install it::
+
+    $ pip install uvloop
+
+
+Using uvloop
+------------
+
+To make asyncio use uvloop, you can install the uvloop event
+loop policy:
+
+.. code:: python
+
+    import asyncio
+    import uvloop
+    asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
+
+Alternatively, you can create an instance of the loop
+manually, using:
+
+.. code:: python
+
+    loop = uvloop.new_event_loop()
+    asyncio.set_event_loop(loop)
+
+
+Development of uvloop
+---------------------
+
+To build uvloop, you'll need Cython and Python 3.5.  The best way
+is to create a virtual env, so that you'll have ``cython`` and
+``python`` commands pointing to the correct tools.
+
+1. ``git clone --recursive git at github.com:MagicStack/uvloop.git``
+
+2. ``cd uvloop``
+
+3. ``make``
+
+4. ``make test``
+
+
+License
+-------
+
+uvloop is dual-licensed under MIT and Apache 2.0 licenses.
diff --git a/docs/api/index.rst b/docs/api/index.rst
new file mode 100644
index 0000000..583d5da
--- /dev/null
+++ b/docs/api/index.rst
@@ -0,0 +1,20 @@
+API
+===
+
+If you are looking for information on a specific function, class or method,
+this part of the documentation is for you.
+
+
+uvloop
+------
+
+.. autoclass:: uvloop.EventLoopPolicy
+  :members:
+
+.. autofunction:: uvloop.new_event_loop
+
+.. autoclass:: uvloop.Loop
+  :members:
+  :undoc-members:
+  :inherited-members:
+
diff --git a/docs/conf.py b/docs/conf.py
new file mode 100644
index 0000000..d4818b9
--- /dev/null
+++ b/docs/conf.py
@@ -0,0 +1,84 @@
+#!/usr/bin/env python3
+
+import alabaster
+import os
+import re
+import sys
+
+sys.path.insert(0, os.path.abspath('..'))
+
+with open(os.path.abspath('../setup.py'), 'rt') as f:
+    _m = re.search(r'''version=(?P<q>'|")(?P<ver>[\d\.]+)(?P=q)''', f.read())
+    if not _m:
+        raise RuntimeError('unable to read the version from setup.py')
+    version = _m.group('ver')
+
+
+# -- General configuration ------------------------------------------------
+
+extensions = [
+    'sphinx.ext.autodoc',
+    'alabaster',
+]
+templates_path = ['_templates']
+source_suffix = '.rst'
+master_doc = 'index'
+project = 'uvloop'
+copyright = '2016-present, MagicStack, Inc'
+author = 'Yury Selivanov'
+release = version
+language = None
+exclude_patterns = ['_build']
+pygments_style = 'sphinx'
+todo_include_todos = False
+
+
+# -- Options for HTML output ----------------------------------------------
+
+html_theme = 'alabaster'
+html_theme_options = {
+    'description': 'uvloop is an ultra fast implementation of the '
+                   'asyncio event loop on top of libuv.',
+    'show_powered_by': False,
+}
+html_theme_path = [alabaster.get_path()]
+html_title = 'uvloop Documentation'
+html_short_title = 'uvloop'
+html_static_path = []
+html_sidebars = {
+    '**': [
+        'about.html',
+        'navigation.html',
+    ]
+}
+html_show_sourcelink = False
+html_show_sphinx = False
+html_show_copyright = True
+htmlhelp_basename = 'uvloopdoc'
+
+
+# -- Options for LaTeX output ---------------------------------------------
+
+latex_elements = {}
+
+latex_documents = [
+    (master_doc, 'uvloop.tex', 'uvloop Documentation',
+     'Yury Selivanov', 'manual'),
+]
+
+
+# -- Options for manual page output ---------------------------------------
+
+man_pages = [
+    (master_doc, 'uvloop', 'uvloop Documentation',
+     [author], 1)
+]
+
+
+# -- Options for Texinfo output -------------------------------------------
+
+texinfo_documents = [
+    (master_doc, 'uvloop', 'uvloop Documentation',
+     author, 'uvloop', 'One line description of project.',
+     'Miscellaneous'),
+]
diff --git a/docs/dev/index.rst b/docs/dev/index.rst
new file mode 100644
index 0000000..7080525
--- /dev/null
+++ b/docs/dev/index.rst
@@ -0,0 +1,124 @@
+Developers Guide
+================
+
+The project is hosted on `GitHub <https://github.com/MagicStack/uvloop>`_.
+and uses `Travis <https://travis-ci.org/MagicStack/uvloop>`_ for
+Continuous Integration.
+
+A goal for the `uvloop` project is to provide a drop in replacement for the
+`asyncio` event loop. Any deviation from the behavior of the reference
+`asyncio` event loop is considered a bug.
+
+If you have found a bug or have an idea for an enhancement that would
+improve the library, use the
+`bug tracker <https://github.com/MagicStack/uvloop/issues>`_.
+
+
+Get the source
+--------------
+
+.. code-block:: console
+
+    $ git clone --recursive git at github.com:MagicStack/uvloop.git
+
+The ``--recursive`` argument is important. It will fetch the ``libuv`` source
+from the `libuv` Github repository.
+
+
+Build
+-----
+
+To build `uvloop`, you'll need ``Cython`` and Python 3.5.
+
+.. note::
+
+    The best way to work on `uvloop` is to create a virtual env, so that
+    you'll have Cython and Python commands pointing to the correct
+    tools.
+
+    .. code-block:: console
+
+        $ python3 -m venv myvenv
+        $ cd myvenv
+        $ source bin/activate
+        $ cd ..
+
+Install Cython if not already present.
+
+.. code-block:: console
+
+    $ pip install Cython
+
+
+Build `uvloop` by running the ``make`` rule from the top level directory.
+
+.. code-block:: console
+
+    $ cd uvloop
+    $ make
+
+
+Test
+----
+
+The easiest method to run all of the unit tests is to run the ``make test``
+rule from the top level directory. This runs the standard library
+``unittest`` tool which discovers all the unit tests and runs them.
+It actually runs them twice, once with the `PYTHONASYNCIODEBUG` enabled and
+once without.
+
+.. code-block:: console
+
+    $ cd uvloop
+    $ make test
+
+
+Individual Tests
+++++++++++++++++
+
+Individual unit tests can be run using the standard library ``unittest``
+or ``pytest`` package.
+
+The easiest approach to ensure that ``uvloop`` can be found by Python is to
+install the package using ``pip``:
+
+.. code-block:: console
+
+    $ cd uvloop
+    $ pip install -e .
+
+You can then run the unit tests individually from the tests directory using
+``unittest``:
+
+.. code-block:: console
+
+    $ cd uvloop/tests
+    $ python -m unittest test_tcp
+
+or using ``pytest``:
+
+.. code-block:: console
+
+    $ cd uvloop/tests
+    $ py.test -k test_signals_sigint_uvcode
+
+
+Documentation
+-------------
+
+To rebuild the project documentation, developers should run the ``make docs``
+rule from the top level directory. It performs a number of steps to create
+a new set of `sphinx <http://sphinx-doc.org/>`_ html content.
+
+This step requires Sphinx to be installed. Sphinx can be installed using
+pip:
+
+.. code-block:: console
+
+    $ pip install sphinx
+
+Once Sphinx is available you can make the documentation using:
+
+.. code-block:: console
+
+    $ make docs
diff --git a/docs/index.rst b/docs/index.rst
new file mode 100644
index 0000000..20ba9af
--- /dev/null
+++ b/docs/index.rst
@@ -0,0 +1,63 @@
+.. image:: https://travis-ci.org/MagicStack/uvloop.svg?branch=master
+    :target: https://travis-ci.org/MagicStack/uvloop
+
+.. image:: https://img.shields.io/pypi/status/uvloop.svg?maxAge=2592000?style=plastic
+    :target: https://pypi.python.org/pypi/uvloop
+
+.. image:: https://img.shields.io/github/stars/magicstack/uvloop.svg?style=social&label=GitHub
+    :target: https://github.com/MagicStack/uvloop
+
+
+uvloop
+======
+
+`uvloop` is a fast, drop-in replacement of the built-in asyncio event loop.
+`uvloop` is released under the MIT license.
+
+`uvloop` and asyncio, combined with the power of async/await in Python 3.5,
+makes it easier than ever to write high-performance networking code in Python.
+
+`uvloop` makes asyncio fast. In fact, it is at least 2x faster than nodejs,
+gevent, as well as any other Python asynchronous framework. The performance of
+uvloop-based asyncio is close to that of Go programs.
+
+You can read more about uvloop in this
+`blog post <http://magic.io/blog/uvloop-blazing-fast-python-networking/>`_.
+
+Architecture
+------------
+
+The asyncio module, introduced by PEP 3156, is a collection of network
+transports, protocols, and streams abstractions, with a pluggable event loop.
+The event loop is the heart of asyncio. It provides APIs for:
+
+- scheduling calls,
+- transmitting data over the network,
+- performing DNS queries,
+- handling OS signals,
+- convenient abstractions to create servers and connections,
+- working with subprocesses asynchronously.
+
+`uvloop` implements the :class:`asyncio.AbstractEventLoop` interface which
+means that it provides a drop-in replacement of the asyncio event loop.
+
+`uvloop` is written in Cython and is built on top of libuv.
+
+libuv is a high performance, multiplatform asynchronous I/O library used by
+nodejs. Because of how wide-spread and popular nodejs is, libuv is fast and
+stable.
+
+`uvloop` implements all asyncio event loop APIs. High-level Python objects
+wrap low-level libuv structs and functions. Inheritance is used to keep the
+code DRY and ensure that any manual memory management is in sync with libuv
+primitives' lifespans.
+
+
+Contents
+--------
+
+.. toctree::
+   :maxdepth: 1
+
+   user/index
+   dev/index
diff --git a/docs/user/index.rst b/docs/user/index.rst
new file mode 100644
index 0000000..8cebfe6
--- /dev/null
+++ b/docs/user/index.rst
@@ -0,0 +1,40 @@
+User Guide
+==========
+
+This section of the documentation provides information about how to use
+uvloop.
+
+
+Installation
+------------
+
+`uvloop` is available from PyPI. It requires Python 3.5.
+
+Use pip to install it.
+
+.. code-block:: console
+
+    $ pip install uvloop
+
+
+Using uvloop
+------------
+
+To make asyncio use the event loop provided by `uvloop`, you install the
+`uvloop` event loop policy:
+
+.. code-block:: python
+
+    import asyncio
+    import uvloop
+    asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
+
+
+Alternatively, you can create an instance of the loop manually, using:
+
+.. code-block:: python
+
+    import asyncio
+    import uvloop
+    loop = uvloop.new_event_loop()
+    asyncio.set_event_loop(loop)
diff --git a/examples/bench/echoclient.py b/examples/bench/echoclient.py
new file mode 100644
index 0000000..1cb121b
--- /dev/null
+++ b/examples/bench/echoclient.py
@@ -0,0 +1,82 @@
+# Copied with minimal modifications from curio
+# https://github.com/dabeaz/curio
+
+
+import argparse
+import time
+
+from concurrent.futures import ProcessPoolExecutor
+from socket import *
+
+
+if __name__ == '__main__':
+    parser = argparse.ArgumentParser()
+    parser.add_argument('--msize', default=1000, type=int,
+                        help='message size in bytes')
+    parser.add_argument('--mpr', default=1, type=int,
+                        help='messages per request')
+    parser.add_argument('--num', default=200000, type=int,
+                        help='number of messages')
+    parser.add_argument('--times', default=1, type=int,
+                        help='number of times to run the test')
+    parser.add_argument('--workers', default=3, type=int,
+                        help='number of workers')
+    parser.add_argument('--addr', default='127.0.0.1:25000', type=str,
+                        help='number of workers')
+    args = parser.parse_args()
+
+    unix = False
+    if args.addr.startswith('file:'):
+        unix = True
+        addr = args.addr[5:]
+    else:
+        addr = args.addr.split(':')
+        addr[1] = int(addr[1])
+        addr = tuple(addr)
+    print('will connect to: {}'.format(addr))
+
+    MSGSIZE = args.msize
+    REQSIZE = MSGSIZE * args.mpr
+
+    msg = b'x'*(MSGSIZE - 1) + b'\n'
+    if args.mpr:
+        msg *= args.mpr
+
+    def run_test(n):
+        print('Sending', NMESSAGES, 'messages')
+        if args.mpr:
+            n //= args.mpr
+
+        if unix:
+            sock = socket(AF_UNIX, SOCK_STREAM)
+        else:
+            sock = socket(AF_INET, SOCK_STREAM)
+
+        try:
+            sock.setsockopt(IPPROTO_TCP, TCP_NODELAY, 1)
+        except (OSError, NameError):
+            pass
+
+        sock.connect(addr)
+        while n > 0:
+            sock.sendall(msg)
+            nrecv = 0
+            while nrecv < REQSIZE:
+                resp = sock.recv(REQSIZE)
+                if not resp:
+                    raise SystemExit()
+                nrecv += len(resp)
+            n -= 1
+
+    TIMES = args.times
+    N = args.workers
+    NMESSAGES = args.num
+    start = time.time()
+    for _ in range(TIMES):
+        with ProcessPoolExecutor(max_workers=N) as e:
+            for _ in range(N):
+                e.submit(run_test, NMESSAGES)
+    end = time.time()
+    duration = end-start
+    print(NMESSAGES*N*TIMES,'in', duration)
+    print(NMESSAGES*N*TIMES/duration, 'requests/sec')
diff --git a/examples/bench/echoserver.py b/examples/bench/echoserver.py
new file mode 100644
index 0000000..364cdd5
--- /dev/null
+++ b/examples/bench/echoserver.py
@@ -0,0 +1,159 @@
+import argparse
+import asyncio
+import gc
+import os.path
+import socket as socket_module
+
+from socket import *
+
+
+PRINT = 0
+
+
+async def echo_server(loop, address, unix):
+    if unix:
+        sock = socket(AF_UNIX, SOCK_STREAM)
+    else:
+        sock = socket(AF_INET, SOCK_STREAM)
+        sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
+    sock.bind(address)
+    sock.listen(5)
+    sock.setblocking(False)
+    if PRINT:
+        print('Server listening at', address)
+    with sock:
+        while True:
+            client, addr = await loop.sock_accept(sock)
+            if PRINT:
+                print('Connection from', addr)
+            loop.create_task(echo_client(loop, client))
+
+
+async def echo_client(loop, client):
+    try:
+        client.setsockopt(IPPROTO_TCP, TCP_NODELAY, 1)
+    except (OSError, NameError):
+        pass
+
+    with client:
+        while True:
+            data = await loop.sock_recv(client, 1000000)
+            if not data:
+                break
+            await loop.sock_sendall(client, data)
+    if PRINT:
... 151835 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/uvloop.git



More information about the Python-modules-commits mailing list