Debian Codegraph @

PKG-INFO

raw
1 Metadata-Version: 2.1
2 Name: aiozmq
3 Version: 1.0.0
4 Summary: ZeroMQ integration with asyncio.
5 Home-page: http://aiozmq.readthedocs.org
6 Download-URL: https://pypi.python.org/pypi/aiozmq
7 Author: Nikolay Kim
8 Author-email: [email protected]
9 Maintainer: Jelle Zijlstra
10 Maintainer-email: [email protected]
11 License: BSD
12 Platform: POSIX
13 Platform: Windows
14 Platform: MacOS X
15 Classifier: License :: OSI Approved :: BSD License
16 Classifier: Intended Audience :: Developers
17 Classifier: Programming Language :: Python :: 3
18 Classifier: Programming Language :: Python :: 3.6
19 Classifier: Programming Language :: Python :: 3.7
20 Classifier: Programming Language :: Python :: 3.8
21 Classifier: Programming Language :: Python :: 3.9
22 Classifier: Programming Language :: Python :: 3.10
23 Classifier: Programming Language :: Python :: 3.11
24 Classifier: Operating System :: POSIX
25 Classifier: Operating System :: MacOS :: MacOS X
26 Classifier: Operating System :: Microsoft :: Windows
27 Classifier: Environment :: Web Environment
28 Classifier: Development Status :: 4 - Beta
29 Classifier: Framework :: AsyncIO
30 Provides-Extra: rpc
31 License-File: LICENSE
32
33 asyncio integration with ZeroMQ
34 ===============================
35
36 asyncio (PEP 3156) support for ZeroMQ.
37
38 .. image:: https://travis-ci.com/aio-libs/aiozmq.svg?branch=master
39 :target: https://travis-ci.com/aio-libs/aiozmq
40
41 The difference between ``aiozmq`` and vanilla ``pyzmq`` (``zmq.asyncio``) is:
42
43 ``zmq.asyncio`` works only by replacing the *base event loop* with a custom one.
44 This approach works but has two disadvantages:
45
46 1. ``zmq.asyncio.ZMQEventLoop`` cannot be combined with
47 other loop implementations (most notable is the ultra fast ``uvloop``).
48
49 2. It uses the internal ZMQ Poller which has fast ZMQ Sockets support
50 but isn't intended to work fast with many (thousands) regular TCP sockets.
51
52 In practice it means that ``zmq.asyncio`` is not recommended to be used with
53 web servers like ``aiohttp``.
54
55 See also https://github.com/zeromq/pyzmq/issues/894
56
57 Documentation
58 -------------
59
60 See http://aiozmq.readthedocs.org
61
62 Simple high-level client-server RPC example:
63
64 .. code-block:: python
65
66 import asyncio
67 import aiozmq.rpc
68
69
70 class ServerHandler(aiozmq.rpc.AttrHandler):
71
72 @aiozmq.rpc.method
73 def remote_func(self, a:int, b:int) -> int:
74 return a + b
75
76
77 async def go():
78 server = await aiozmq.rpc.serve_rpc(
79 ServerHandler(), bind='tcp://127.0.0.1:5555')
80 client = await aiozmq.rpc.connect_rpc(
81 connect='tcp://127.0.0.1:5555')
82
83 ret = await client.call.remote_func(1, 2)
84 assert 3 == ret
85
86 server.close()
87 client.close()
88
89 asyncio.run(go())
90
91 Low-level request-reply example:
92
93 .. code-block:: python
94
95 import asyncio
96 import aiozmq
97 import zmq
98
99 async def go():
100 router = await aiozmq.create_zmq_stream(
101 zmq.ROUTER,
102 bind='tcp://127.0.0.1:*')
103
104 addr = list(router.transport.bindings())[0]
105 dealer = await aiozmq.create_zmq_stream(
106 zmq.DEALER,
107 connect=addr)
108
109 for i in range(10):
110 msg = (b'data', b'ask', str(i).encode('utf-8'))
111 dealer.write(msg)
112 data = await router.read()
113 router.write(data)
114 answer = await dealer.read()
115 print(answer)
116 dealer.close()
117 router.close()
118
119 asyncio.run(go())
120
121
122 Comparison to pyzmq
123 -------------------
124
125 ``zmq.asyncio`` provides an *asyncio compatible loop* implementation.
126
127 But it's based on ``zmq.Poller`` which doesn't work well with massive
128 non-zmq socket usage.
129
130 E.g. if you build a web server for handling at least thousands of
131 parallel web requests (1000-5000) ``pyzmq``'s internal poller will be slow.
132
133 ``aiozmq`` works with epoll natively, it doesn't need a custom loop
134 implementation and cooperates pretty well with `uvloop` for example.
135
136 For details see https://github.com/zeromq/pyzmq/issues/894
137
138
139 Requirements
140 ------------
141
142 * Python_ 3.6+
143 * pyzmq_ 13.1+
144 * optional submodule ``aiozmq.rpc`` requires msgpack_ 0.5+
145
146
147
148 License
149 -------
150
151 aiozmq is offered under the BSD license.
152
153 .. _python: https://www.python.org/
154 .. _pyzmq: https://pypi.python.org/pypi/pyzmq
155 .. _asyncio: https://pypi.python.org/pypi/asyncio
156 .. _msgpack: https://pypi.python.org/pypi/msgpack
157
158 CHANGES
159 -------
160
161 1.0.0 (2022-11-02)
162 ^^^^^^^^^^^^^^^^^^
163
164 * Support Python 3.9, 3.10, and 3.11 (thanks in part to Esben Sonne)
165
166 * Drop support for Python 3.5
167
168 * Remove support for using annotations as conversion functions
169
170
171 0.9.0 (2020-01-25)
172 ^^^^^^^^^^^^^^^^^^
173
174 * Support Python 3.7 and 3.8
175
176 0.8.0 (2016-12-07)
177 ^^^^^^^^^^^^^^^^^^
178
179 * Respect `events_backlog` parameter in zmq stream creation #86
180
181 0.7.1 (2015-09-20)
182 ^^^^^^^^^^^^^^^^^^
183
184 * Fix monitoring events implementation
185
186 * Make the library compatible with Python 3.5
187
188 0.7.0 (2015-07-31)
189 ^^^^^^^^^^^^^^^^^^
190
191 * Implement monitoring ZMQ events #50
192
193 * Do deeper lookup for inhereted classes #54
194
195 * Relax endpont check #56
196
197 * Implement monitoring events for stream api #52
198
199 0.6.1 (2015-05-19)
200 ^^^^^^^^^^^^^^^^^^
201
202 * Dynamically get list of pyzmq socket types
203
204 0.6.0 (2015-02-14)
205 ^^^^^^^^^^^^^^^^^^
206
207 * Process asyncio specific exceptions as builtins.
208
209 * Add repr(exception) to rpc server call logs if any
210
211 * Add transport.get_write_buffer_limits() method
212
213 * Add __repr__ to transport
214
215 * Add zmq_type to tr.get_extra_info()
216
217 * Add zmq streams
218
219 0.5.2 (2014-10-09)
220 ^^^^^^^^^^^^^^^^^^
221
222 * Poll events after sending zmq message for eventless transport
223
224 0.5.1 (2014-09-27)
225 ^^^^^^^^^^^^^^^^^^
226
227 * Fix loopless transport implementation.
228
229 0.5.0 (2014-08-23)
230 ^^^^^^^^^^^^^^^^^^
231
232 * Support zmq devices in aiozmq.rpc.serve_rpc()
233
234 * Add loopless 0MQ transport
235
236 0.4.1 (2014-07-03)
237 ^^^^^^^^^^^^^^^^^^
238
239 * Add exclude_log_exceptions parameter to rpc servers.
240
241 0.4.0 (2014-05-28)
242 ^^^^^^^^^^^^^^^^^^
243
244 * Implement pause_reading/resume_reading methods in ZmqTransport.
245
246 0.3.0 (2014-05-17)
247 ^^^^^^^^^^^^^^^^^^
248
249 * Add limited support for Windows.
250
251 * Fix unstable test execution, change ZmqEventLoop to use global
252 shared zmq.Context by default.
253
254 * Process cancellation on rpc servers and clients.
255
256 0.2.0 (2014-04-18)
257 ^^^^^^^^^^^^^^^^^^
258
259 * msg in msg_received now is a list, not tuple
260
261 * Allow to send empty msg by trsansport.write()
262
263 * Add benchmarks
264
265 * Derive ServiceClosedError from aiozmq.rpc.Error, not Exception
266
267 * Implement logging from remote calls at server side (log_exceptions parameter).
268
269 * Optimize byte counting in ZmqTransport.
270
271 0.1.3 (2014-04-10)
272 ^^^^^^^^^^^^^^^^^^
273
274 * Function default values are not passed to an annotaion.
275 Add check for libzmq version (should be >= 3.0)
276
277 0.1.2 (2014-04-01)
278 ^^^^^^^^^^^^^^^^^^
279
280 * Function default values are not passed to an annotaion.
281
282 0.1.1 (2014-03-31)
283 ^^^^^^^^^^^^^^^^^^
284
285 * Rename plural module names to single ones.
286
287 0.1.0 (2014-03-30)
288 ^^^^^^^^^^^^^^^^^^
289
290 * Implement ZmqEventLoop with *create_zmq_connection* method which operates
291 on zmq transport and protocol.
292
293 * Implement ZmqEventLoopPolicy.
294
295 * Introduce ZmqTransport and ZmqProtocol.
296
297 * Implement zmq.rpc with RPC, PUSHPULL and PUBSUB protocols.