Skip to content

Commit 679088b

Browse files
committed
Bump zmq-anyio v0.3.6
1 parent cdfe144 commit 679088b

File tree

3 files changed

+39
-38
lines changed

3 files changed

+39
-38
lines changed

ipykernel/iostream.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ async def _run_event_pipe_gc(self):
9797
while True:
9898
await sleep(self._event_pipe_gc_seconds)
9999
try:
100-
await self._event_pipe_gc()
100+
self._event_pipe_gc()
101101
except Exception as e:
102102
print(f"Exception in IOPubThread._event_pipe_gc: {e}", file=sys.__stderr__)
103103

104-
async def _event_pipe_gc(self):
104+
def _event_pipe_gc(self):
105105
"""run a single garbage collection on event pipes"""
106106
if not self._event_pipes:
107107
# don't acquire the lock if there's nothing to do

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ dependencies = [
3333
"psutil>=5.7",
3434
"packaging>=22",
3535
"anyio>=4.8.0,<5.0.0",
36-
"zmq-anyio >=0.3.5",
36+
"zmq-anyio >=0.3.6",
3737
]
3838

3939
[project.urls]

tests/test_io.py

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ async def test_outstream(iopub_thread):
127127
assert stream.writable()
128128

129129

130+
@pytest.mark.skip(reason="Cannot use a zmq-anyio socket on different threads")
130131
async def test_event_pipe_gc(iopub_thread):
131132
session = Session(key=b"abc")
132133
stream = OutStream(
@@ -147,7 +148,7 @@ async def test_event_pipe_gc(iopub_thread):
147148
f: Future = Future()
148149

149150
try:
150-
await iopub_thread._event_pipe_gc()
151+
iopub_thread._event_pipe_gc()
151152
except Exception as e:
152153
f.set_exception(e)
153154
else:
@@ -164,41 +165,41 @@ async def subprocess_test_echo_watch():
164165

165166
# use PUSH socket to avoid subscription issues
166167
with zmq.Context() as ctx:
167-
async with zmq_anyio.Socket(ctx.socket(zmq.PUSH)) as pub:
168-
pub.connect(os.environ["IOPUB_URL"])
169-
iopub_thread = IOPubThread(pub)
170-
iopub_thread.start()
171-
stdout_fd = sys.stdout.fileno()
168+
pub = zmq_anyio.Socket(ctx.socket(zmq.PUSH))
169+
pub.connect(os.environ["IOPUB_URL"])
170+
iopub_thread = IOPubThread(pub)
171+
iopub_thread.start()
172+
stdout_fd = sys.stdout.fileno()
173+
sys.stdout.flush()
174+
stream = OutStream(
175+
session,
176+
iopub_thread,
177+
"stdout",
178+
isatty=True,
179+
echo=sys.stdout,
180+
watchfd="force",
181+
)
182+
save_stdout = sys.stdout
183+
with stream, mock.patch.object(sys, "stdout", stream):
184+
# write to low-level FD
185+
os.write(stdout_fd, b"fd\n")
186+
# print (writes to stream)
187+
print("print\n", end="")
172188
sys.stdout.flush()
173-
stream = OutStream(
174-
session,
175-
iopub_thread,
176-
"stdout",
177-
isatty=True,
178-
echo=sys.stdout,
179-
watchfd="force",
180-
)
181-
save_stdout = sys.stdout
182-
with stream, mock.patch.object(sys, "stdout", stream):
183-
# write to low-level FD
184-
os.write(stdout_fd, b"fd\n")
185-
# print (writes to stream)
186-
print("print\n", end="")
187-
sys.stdout.flush()
188-
# write to unwrapped __stdout__ (should also go to original FD)
189-
sys.__stdout__.write("__stdout__\n")
190-
sys.__stdout__.flush()
191-
# write to original sys.stdout (should be the same as __stdout__)
192-
save_stdout.write("stdout\n")
193-
save_stdout.flush()
194-
# is there another way to flush on the FD?
195-
fd_file = os.fdopen(stdout_fd, "w")
196-
fd_file.flush()
197-
# we don't have a sync flush on _reading_ from the watched pipe
198-
time.sleep(1)
199-
stream.flush()
200-
iopub_thread.stop()
201-
iopub_thread.close()
189+
# write to unwrapped __stdout__ (should also go to original FD)
190+
sys.__stdout__.write("__stdout__\n")
191+
sys.__stdout__.flush()
192+
# write to original sys.stdout (should be the same as __stdout__)
193+
save_stdout.write("stdout\n")
194+
save_stdout.flush()
195+
# is there another way to flush on the FD?
196+
fd_file = os.fdopen(stdout_fd, "w")
197+
fd_file.flush()
198+
# we don't have a sync flush on _reading_ from the watched pipe
199+
time.sleep(1)
200+
stream.flush()
201+
iopub_thread.stop()
202+
iopub_thread.close()
202203

203204

204205
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Windows")

0 commit comments

Comments
 (0)