Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ if (NOT PYZMQ_BACKEND)
set(PYZMQ_BACKEND "cffi")
else()
set(PYZMQ_BACKEND "cython")
add_compile_definitions(CYTHON_USE_MODULE_STATE=1)
endif()
endif()

Expand Down
36 changes: 36 additions & 0 deletions tests/test_subshell.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import sys

import pytest
from conftest import recv

import zmq

if sys.version_info < (3, 14):
pytest.skip("Requires Python 3.14")

from concurrent.futures import InterpreterPoolExecutor


def echo(url):
with zmq.Context() as ctx, ctx.socket(zmq.ROUTER) as s:
s.bind(url)
msg = s.recv_multipart()
print(msg)


def test_subshell(context, socket):
s = socket(zmq.DEALER)
url = "tcp://127.0.0.1:5555"
with InterpreterPoolExecutor(1) as pool:
f = pool.submit(echo, url)
try:
f.result(timeout=1)
except TimeoutError:
pass
else:
pytest.fail("echo task exited prematurely...")
s.connect(url)
msg = b"msg"
s.send(msg)
recvd = recv(s)
assert recvd == msg
7 changes: 6 additions & 1 deletion zmq/backend/cython/_zmq.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# cython: language_level = 3str
# cython: freethreading_compatible = True
# cython: subinterpreters_compatible = own_gil

"""Cython backend for pyzmq"""

# Copyright (C) PyZMQ Developers
Expand Down Expand Up @@ -49,6 +51,7 @@
cfunc,
char,
declare,
exceptval,
inline,
nogil,
p_char,
Expand Down Expand Up @@ -169,7 +172,7 @@

@cfunc
@inline
@C.exceptval(-1)
@exceptval(-1)
def _check_rc(rc: C.int, error_without_errno: bint = False) -> C.int:
"""internal utility for checking zmq return condition

Expand Down Expand Up @@ -1804,6 +1807,7 @@ def proxy_steerable(
@cfunc
@inline
@nogil
@exceptval(check=False)
def _mq_relay(
in_socket: p_void,
out_socket: p_void,
Expand Down Expand Up @@ -1887,6 +1891,7 @@ def _mq_relay(
@cfunc
@inline
@nogil
@exceptval(check=False)
def _mq_inline(
in_socket: p_void,
out_socket: p_void,
Expand Down
Loading