File: zmq.md

package info (click to toggle)
pyzmq 27.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,984 kB
  • sloc: python: 15,189; ansic: 285; makefile: 169; sh: 85
file content (290 lines) | stat: -rw-r--r-- 4,999 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# zmq

```{eval-rst}
.. automodule:: zmq
```

```{currentmodule} zmq
```

## Basic Classes

````{note}
For typing purposes, {class}`.zmq.Context` and {class}`.zmq.Socket` are Generics,
which means they will accept any Context or Socket implementation.

The base {class}`zmq.Context()` constructor returns the type
`zmq.Context[zmq.Socket[bytes]]`.
If you are using type annotations and want to _exclude_ the async subclasses,
use the resolved types instead of the base Generics:

```python
ctx: zmq.Context[zmq.Socket[bytes]] = zmq.Context()
sock: zmq.Socket[bytes]
```

in pyzmq 26, these are available as the Type Aliases (not actual classes!):

```python
ctx: zmq.SyncContext = zmq.Context()
sock: zmq.SyncSocket
```

````

## {class}`Context`

```{eval-rst}
.. autoclass:: Context
  :members:
  :inherited-members:
  :exclude-members: sockopts, closed, __del__, __enter__, __exit__, __copy__, __deepcopy__, __delattr__, __getattr__, __setattr__,

  .. attribute:: closed

      boolean - whether the context has been terminated.
      If True, you can no longer use this Context.

```

## {class}`Socket`

```{eval-rst}
.. autoclass:: Socket
  :members:
  :inherited-members:
  :exclude-members: closed, context, getsockopt_unicode, recv_unicode, setsockopt_unicode, send_unicode, __del__, __enter__, __exit__, __copy__, __deepcopy__, __delattr__, __getattr__, __setattr__,

  .. attribute:: closed

      boolean - whether the socket has been closed.
      If True, you can no longer use this Socket.

  .. attribute:: copy_threshold

      integer - size (in bytes) below which messages
      should always be copied.
      Zero-copy support has nontrivial overhead
      due to the need to coordinate garbage collection
      with the libzmq IO thread,
      so sending small messages (typically < 10s of kB)
      with ``copy=False`` is often more expensive
      than with ``copy=True``.
      The initial default value is 65536 (64kB),
      a reasonable default based on testing.

      Defaults to :const:`zmq.COPY_THRESHOLD` on socket construction.
      Setting :const:`zmq.COPY_THRESHOLD` will define the default
      value for any subsequently created sockets.

      .. versionadded:: 17

```

## {class}`Frame`

```{eval-rst}
.. autoclass:: Frame
  :members:
  :inherited-members:

```

## {class}`MessageTracker`

```{eval-rst}
.. autoclass:: MessageTracker
  :members:
  :inherited-members:

```

## {class}`Poller`

```{eval-rst}
.. autoclass:: Poller
  :members:
  :inherited-members:

```

```{eval-rst}
.. autofunction:: zmq.select
```

## Constants

All libzmq constants are available as top-level attributes
(`zmq.PUSH`, etc.),
as well as via enums (`zmq.SocketType.PUSH`, etc.).

```{versionchanged} 23
constants for unavailable socket types
or draft features will always be defined in pyzmq,
whether the features themselves are available or not.
```

```{versionadded} 23
Each category of zmq constant is now available as an IntEnum.
```

```{eval-rst}
.. data:: COPY_THRESHOLD

    The global default "small message" threshold for copying when `copy=False`.
    Copying has a thread-coordination cost, so zero-copy only has a benefit for sufficiently large messages.
```

```{eval-rst}
.. autoenum:: SocketType
```

```{eval-rst}
.. autoenum:: SocketOption
```

```{eval-rst}
.. autoenum:: Flag
```

```{eval-rst}
.. autoenum:: PollEvent
```

```{eval-rst}
.. autoenum:: ContextOption
```

```{eval-rst}
.. autoenum:: MessageOption
```

```{eval-rst}
.. autoenum:: Event
```

```{eval-rst}
.. autoenum:: NormMode
```

```{eval-rst}
.. autoenum:: RouterNotify
```

```{eval-rst}
.. autoenum:: ReconnectStop
```

```{eval-rst}
.. autoenum:: SecurityMechanism
```

```{eval-rst}
.. autoenum:: DeviceType
```

```{eval-rst}
.. autoenum:: Errno
```

## Exceptions

### {class}`ZMQError`

```{eval-rst}
.. autoclass:: ZMQError
  :members:
  :inherited-members:

```

### {class}`ZMQVersionError`

```{eval-rst}
.. autoclass:: ZMQVersionError
  :members:
  :inherited-members:
```

### {class}`Again`

```{eval-rst}
.. autoclass:: Again

```

### {class}`ContextTerminated`

```{eval-rst}
.. autoclass:: ContextTerminated

```

### {class}`NotDone`

```{eval-rst}
.. autoclass:: NotDone

```

### {class}`ZMQBindError`

```{eval-rst}
.. autoclass:: ZMQBindError


```

## Functions

```{eval-rst}
.. autofunction:: zmq.zmq_version
```

```{eval-rst}
.. autofunction:: zmq.pyzmq_version
```

```{eval-rst}
.. autofunction:: zmq.zmq_version_info
```

```{eval-rst}
.. autofunction:: zmq.pyzmq_version_info
```

```{eval-rst}
.. autofunction:: zmq.has
```

```{eval-rst}
.. autofunction:: zmq.device
```

```{eval-rst}
.. autofunction:: zmq.proxy
```

```{eval-rst}
.. autofunction:: zmq.proxy_steerable
```

```{eval-rst}
.. autofunction:: zmq.curve_public
```

```{eval-rst}
.. autofunction:: zmq.curve_keypair
```

```{eval-rst}
.. autofunction:: zmq.get_includes
```

```{eval-rst}
.. autofunction:: zmq.get_library_dirs
```

```{eval-rst}
.. autofunction:: zmq.strerror
```