Skip to content

interpreters.InterpreterError: RuntimeError: _interpqueues module not imported yet #20

@Jamie-Chang

Description

@Jamie-Chang

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions