Files
RustPython/extra_tests/snippets/stdlib_subinterpreters.py
T
Jeong, YunWon 6aac4653e6 Fix post-merge subinterpreter lifecycle issues (#8632)
Preserve logical memoryview descriptors across interpreter transfers, make channel-end release idempotent, and scope runtime-owned interpreter cleanup to the creating top-level runtime. Re-read owned interpreters during shutdown so finalizers cannot leave newly-created children behind.

Add regression coverage for sliced and cast memoryviews, repeated channel release, and multiple embedded runtimes.

Assisted-by: Codex:GPT-5
2026-09-01 08:47:43 +09:00

24 lines
695 B
Python

import _interpchannels
import _interpreters
def roundtrip_buffer(view):
cid = _interpchannels.create(3)
try:
_interpchannels.send_buffer(cid, view, blocking=False)
received, unbound = _interpchannels.recv(cid)
assert unbound is None
return received
finally:
_interpchannels.destroy(cid)
data = bytearray(range(12))
for view in (memoryview(data)[2:10:2], memoryview(data).cast("I")):
received = roundtrip_buffer(view)
assert received.tolist() == view.tolist()
assert received.shape == view.shape
assert received.strides == view.strides
assert received.format == view.format
assert received.itemsize == view.itemsize