-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Python version: 3.13 with gil enabled
I tried to follow examples in PEP-734 but couldn't pass the queue using Interpreter.prepare_main
To reproduce
from interpreters_backport import interpreters
interp = interpreters.create()
queue = interpreters.create_queue()
interp.prepare_main(queue=queue)this gives us
interpreters.InterpreterError: RuntimeError: _interpqueues module not imported yet
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/jamie.chang/personal-projects/advent2024-python/queue_bug.py", line 5, in <module>
interp.prepare_main(queue=queue)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
File "/Users/jamie.chang/personal-projects/advent2024-python/.venv/lib/python3.13/site-packages/interpreters_backport/interpreters/__init__.py", line 211, in prepare_main
_interpreters.set___main___attrs(self._id, ns, restrict=True)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
interpreters.InterpreterError: failed to apply namespace to __main__
I was able to workaround the issue by using the Queue.id inside the interpreter
from textwrap import dedent
from interpreters_backport import interpreters
interp = interpreters.create()
queue = interpreters.create_queue()
interp.exec(
dedent(f"""
from interpreters_backport import interpreters
tasks = interpreters.Queue({queue.id})
""")
)Let me know if this is supposed to go to the upstream, I'm not sure if the issue is in the backport or cpython
Metadata
Metadata
Assignees
Labels
No labels