mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
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
24 lines
695 B
Python
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
|