Debian Codegraph @

PKG-INFO

raw
1 Metadata-Version: 1.2
2 Name: async_generator
3 Version: 1.10
4 Summary: Async generators and context managers for Python 3.5+
5 Home-page: https://github.com/python-trio/async_generator
6 Author: Nathaniel J. Smith
7 Author-email: [email protected]
8 License: MIT -or- Apache License 2.0
9 Description: .. image:: https://img.shields.io/badge/chat-join%20now-blue.svg
10 :target: https://gitter.im/python-trio/general
11 :alt: Join chatroom
12
13 .. image:: https://img.shields.io/badge/docs-read%20now-blue.svg
14 :target: https://async-generator.readthedocs.io/en/latest/?badge=latest
15 :alt: Documentation Status
16
17 .. image:: https://travis-ci.org/python-trio/async_generator.svg?branch=master
18 :target: https://travis-ci.org/python-trio/async_generator
19 :alt: Automated test status
20
21 .. image:: https://ci.appveyor.com/api/projects/status/af4eyed8o8tc3t0r/branch/master?svg=true
22 :target: https://ci.appveyor.com/project/python-trio/trio/history
23 :alt: Automated test status (Windows)
24
25 .. image:: https://codecov.io/gh/python-trio/async_generator/branch/master/graph/badge.svg
26 :target: https://codecov.io/gh/python-trio/async_generator
27 :alt: Test coverage
28
29 The async_generator library
30 ===========================
31
32 Python 3.6 added `async generators
33 <https://www.python.org/dev/peps/pep-0525/>`__. (What's an async
34 generator? `Check out my 5-minute lightning talk demo from PyCon 2016
35 <https://youtu.be/PulzIT8KYLk?t=24m30s>`__.) Python 3.7 adds some more
36 tools to make them usable, like ``contextlib.asynccontextmanager``.
37
38 This library gives you all that back to Python 3.5.
39
40 For example, this code only works in Python 3.6+:
41
42 .. code-block:: python3
43
44 async def load_json_lines(stream_reader):
45 async for line in stream_reader:
46 yield json.loads(line)
47
48 But this code does the same thing, and works on Python 3.5+:
49
50 .. code-block:: python3
51
52 from async_generator import async_generator, yield_
53
54 @async_generator
55 async def load_json_lines(stream_reader):
56 async for line in stream_reader:
57 await yield_(json.loads(line))
58
59 Or in Python 3.7, you can write:
60
61 .. code-block:: python3
62
63 from contextlib import asynccontextmanager
64
65 @asynccontextmanager
66 async def background_server():
67 async with trio.open_nursery() as nursery:
68 value = await nursery.start(my_server)
69 try:
70 yield value
71 finally:
72 # Kill the server when the scope exits
73 nursery.cancel_scope.cancel()
74
75 This is the same, but back to 3.5:
76
77 .. code-block:: python3
78
79 from async_generator import async_generator, yield_, asynccontextmanager
80
81 @asynccontextmanager
82 @async_generator
83 async def background_server():
84 async with trio.open_nursery() as nursery:
85 value = await nursery.start(my_server)
86 try:
87 await yield_(value)
88 finally:
89 # Kill the server when the scope exits
90 nursery.cancel_scope.cancel()
91
92 (And if you're on 3.6, you can use ``@asynccontextmanager`` with
93 native generators.)
94
95
96 Let's do this
97 =============
98
99 * Install: ``python3 -m pip install -U async_generator`` (or on Windows,
100 maybe ``py -3 -m pip install -U async_generator``
101
102 * Manual: https://async-generator.readthedocs.io/
103
104 * Bug tracker and source code: https://github.com/python-trio/async_generator
105
106 * Real-time chat: https://gitter.im/python-trio/general
107
108 * License: MIT or Apache 2, your choice
109
110 * Contributor guide: https://trio.readthedocs.io/en/latest/contributing.html
111
112 * Code of conduct: Contributors are requested to follow our `code of
113 conduct
114 <https://trio.readthedocs.io/en/latest/code-of-conduct.html>`__ in
115 all project spaces.
116
117
118 How come some of those links talk about "trio"?
119 ===============================================
120
121 `Trio <https://trio.readthedocs.io>`__ is a new async concurrency
122 library for Python that's obsessed with usability and correctness – we
123 want to make it *easy* to get things *right*. The ``async_generator``
124 library is maintained by the Trio project as part of that mission, and
125 because Trio uses ``async_generator`` internally.
126
127 You can use ``async_generator`` with any async library. It works great
128 with ``asyncio``, or Twisted, or whatever you like. (But we think Trio
129 is pretty sweet.)
130
131 Keywords: async
132 Platform: UNKNOWN
133 Classifier: Development Status :: 5 - Production/Stable
134 Classifier: Intended Audience :: Developers
135 Classifier: License :: OSI Approved :: MIT License
136 Classifier: License :: OSI Approved :: Apache Software License
137 Classifier: Programming Language :: Python :: Implementation :: CPython
138 Classifier: Programming Language :: Python :: Implementation :: PyPy
139 Classifier: Programming Language :: Python :: 3 :: Only
140 Classifier: Programming Language :: Python :: 3.5
141 Classifier: Programming Language :: Python :: 3.6
142 Classifier: Framework :: AsyncIO
143 Requires-Python: >=3.5