Skip to content

Commit 842a6c0

Browse files
committed
move zmq.device out of backends
it's a deprecated wrapper for zmq.proxy, no need to have two implementations
1 parent 0b46d59 commit 842a6c0

File tree

10 files changed

+23
-54
lines changed

10 files changed

+23
-54
lines changed

zmq/__init__.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ __version__: str
1414
from .backend import IPC_PATH_MAX_LEN as IPC_PATH_MAX_LEN
1515
from .backend import curve_keypair as curve_keypair
1616
from .backend import curve_public as curve_public
17-
from .backend import device as device
1817
from .backend import has as has
1918
from .backend import proxy as proxy
2019
from .backend import proxy_steerable as proxy_steerable

zmq/backend/__init__.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ def zmq_version_info() -> tuple[int, int, int]: ...
111111
def zmq_poll(
112112
sockets: list[Any], timeout: int | None = ...
113113
) -> list[tuple[Socket, int]]: ...
114-
def device(device_type: int, frontend: Socket, backend: Socket | None = ...) -> int: ...
115114
def proxy(frontend: Socket, backend: Socket, capture: Socket | None = None) -> int: ...
116115
def proxy_steerable(
117116
frontend: Socket,

zmq/backend/cffi/_cdefs.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ int zmq_connect(void *socket, const char *endpoint);
99
int zmq_errno(void);
1010
const char * zmq_strerror(int errnum);
1111

12-
int zmq_device(int device, void *frontend, void *backend);
13-
1412
int zmq_unbind(void *socket, const char *endpoint);
1513
int zmq_disconnect(void *socket, const char *endpoint);
1614
void* zmq_ctx_new();

zmq/backend/cffi/devices.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
from .utils import _retry_sys_call
1010

1111

12-
def device(device_type, frontend, backend):
13-
return proxy(frontend, backend)
14-
15-
1612
def proxy(frontend, backend, capture=None):
1713
if isinstance(capture, Socket):
1814
capture = capture._zmq_socket
@@ -60,4 +56,4 @@ def proxy_steerable(frontend, backend, capture=None, control=None):
6056
)
6157

6258

63-
__all__ = ['device', 'proxy', 'proxy_steerable']
59+
__all__ = ['proxy', 'proxy_steerable']

zmq/backend/cython/_zmq.py

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@
105105
zmq_ctx_set,
106106
zmq_curve_keypair,
107107
zmq_curve_public,
108-
zmq_device,
109108
zmq_disconnect,
110109
zmq_free_fn,
111110
zmq_getsockopt,
@@ -1678,42 +1677,6 @@ def zmq_poll(sockets, timeout: C.int = -1):
16781677
return results
16791678

16801679

1681-
# device functions
1682-
1683-
1684-
def device(device_type: C.int, frontend: Socket, backend: Socket = None):
1685-
"""
1686-
Start a zeromq device.
1687-
1688-
.. deprecated:: libzmq-3.2
1689-
Use zmq.proxy
1690-
1691-
Parameters
1692-
----------
1693-
device_type : int
1694-
one of: QUEUE, FORWARDER, STREAMER
1695-
The type of device to start.
1696-
frontend : Socket
1697-
The Socket instance for the incoming traffic.
1698-
backend : Socket
1699-
The Socket instance for the outbound traffic.
1700-
"""
1701-
if ZMQ_VERSION_MAJOR >= 3:
1702-
return proxy(frontend, backend)
1703-
1704-
rc: C.int = 0
1705-
while True:
1706-
with nogil:
1707-
rc = zmq_device(device_type, frontend.handle, backend.handle)
1708-
try:
1709-
_check_rc(rc)
1710-
except InterruptedSystemCall:
1711-
continue
1712-
else:
1713-
break
1714-
return rc
1715-
1716-
17171680
def proxy(frontend: Socket, backend: Socket, capture: Socket = None):
17181681
"""
17191682
Start a zeromq proxy (replacement for device).
@@ -2038,7 +2001,6 @@ def monitored_queue(
20382001
'zmq_errno',
20392002
'zmq_poll',
20402003
'strerror',
2041-
'device',
20422004
'proxy',
20432005
'proxy_steerable',
20442006
]

zmq/backend/cython/libzmq.pxd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ cdef extern from "zmq.h" nogil:
102102

103103
int zmq_poll (zmq_pollitem_t *items, int nitems, long timeout)
104104

105-
int zmq_device (int device_, void *insocket_, void *outsocket_)
106105
int zmq_proxy (void *frontend, void *backend, void *capture)
107106
int zmq_proxy_steerable (void *frontend,
108107
void *backend,

zmq/backend/select.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
'Socket',
1212
'Frame',
1313
'Message',
14-
'device',
1514
'proxy',
1615
'proxy_steerable',
1716
'zmq_poll',

zmq/devices/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
# Copyright (C) PyZMQ Developers
44
# Distributed under the terms of the Modified BSD License.
55

6-
from zmq import device
6+
from __future__ import annotations
7+
8+
from zmq import DeviceType, proxy
79
from zmq.devices import (
810
basedevice,
911
monitoredqueue,
@@ -17,7 +19,7 @@
1719
from zmq.devices.proxydevice import *
1820
from zmq.devices.proxysteerabledevice import *
1921

20-
__all__ = ['device']
22+
__all__ = []
2123
for submod in (
2224
basedevice,
2325
proxydevice,

zmq/devices/basedevice.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from typing import Any, Callable, List, Optional, Tuple
1010

1111
import zmq
12-
from zmq import ENOTSOCK, ETERM, PUSH, QUEUE, Context, ZMQBindError, ZMQError, device
12+
from zmq import ENOTSOCK, ETERM, PUSH, QUEUE, Context, ZMQBindError, ZMQError, proxy
1313

1414

1515
class Device:
@@ -233,7 +233,7 @@ def run_device(self) -> None:
233233
Do not call me directly, instead call ``self.start()``, just like a Thread.
234234
"""
235235
ins, outs = self._setup_sockets()
236-
device(self.device_type, ins, outs)
236+
proxy(ins, outs)
237237

238238
def _close_sockets(self):
239239
"""Cleanup sockets we created"""

zmq/sugar/__init__.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,25 @@
33
# Copyright (C) PyZMQ Developers
44
# Distributed under the terms of the Modified BSD License.
55

6+
from __future__ import annotations
7+
68
from zmq import error
9+
from zmq.backend import proxy
10+
from zmq.constants import DeviceType
711
from zmq.sugar import context, frame, poll, socket, tracker, version
812

9-
__all__ = []
13+
14+
def device(device_type: DeviceType, frontend: socket.Socket, backend: socket.Socket):
15+
"""Deprecated alias for zmq.proxy
16+
17+
.. versiondeprecated:: libzmq-3.2
18+
.. versiondeprecated:: 13.0
19+
"""
20+
21+
return proxy(frontend, backend)
22+
23+
24+
__all__ = ["device"]
1025
for submod in (context, error, frame, poll, socket, tracker, version):
1126
__all__.extend(submod.__all__)
1227

0 commit comments

Comments
 (0)