Skip to content

./python -m test test_interpreters test_struct fails with: KeyError: concurrent.interpreters._queues.UNBOUND #142414

Closed

Description

@ppigazzini

Bug report

Bug description:

I routinely use on my Ubuntu machines pyenv and a script to install python versions:

Click to view
 python_ver=3.14.2

# setup pyenv and install latest python
# https://github.com/pyenv/pyenv
# https://github.com/python/pyperformance

if ! command -v pyenv &>/dev/null; then
  # dependencies according to pyenv
  #sudo apt update; sudo apt install -y build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev

  # Workaround missing libmpdec-dev on ubuntu 24.04 (it should be re introduced in ubuntu 26.04):
  # https://launchpad.net/~ondrej/+archive/ubuntu/php
  # https://deb.sury.org/
  sudo add-apt-repository -y ppa:ondrej/php

  # dependencies according to python build doc dropping packages used in CI (ccache, cmake, gdb, inetutils-inetd, lcov, lzma, strace, xvfb)
  # https://devguide.python.org/getting-started/setup-building/index.html#build-dependencies
  # https://github.com/python/cpython/blob/main/.github/workflows/posix-deps-apt.sh
  sudo apt update; sudo apt install -y build-essential pkg-config libb2-dev libbz2-dev libffi-dev libgdbm-dev libgdbm-compat-dev liblzma-dev libncurses5-dev libreadline6-dev libsqlite3-dev libssl-dev lzma-dev tk-dev uuid-dev zlib1g-dev libzstd-dev libmpdec-dev

  pyenv_dir="$HOME/.pyenv"
  git clone https://github.com/pyenv/pyenv.git "$pyenv_dir"

  cat << 'EOF' >> "$HOME/.profile"

# pyenv: keep at the end of the file
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
EOF

  cat << 'EOF' >> "$HOME/.bashrc"

# pyenv: keep at the end of the file
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
EOF

  . "$HOME/.profile"
  pushd "$pyenv_dir" && src/configure && make -C src && popd
  #CC="clang" CXX="clang++" LDFLAGS="${LDFLAGS:+$LDFLAGS }-fuse-ld=lld" PYTHON_CONFIGURE_OPTS="--enable-optimizations --with-lto --with-tail-call-interp --enable-bolt" PYTHON_CFLAGS="-march=native -mtune=native" pyenv install "$python_ver"
  CC="clang" CXX="clang++" LDFLAGS="${LDFLAGS:+$LDFLAGS }-fuse-ld=lld" PYTHON_CONFIGURE_OPTS="--enable-optimizations --with-lto" PYTHON_CFLAGS="-march=native -mtune=native" pyenv install "$python_ver"
  #PYTHON_CONFIGURE_OPTS="--enable-optimizations --with-lto" PYTHON_CFLAGS="-march=native -mtune=native" pyenv install "$python_ver"
  pyenv global "$python_ver"
fi

test_struct fails in python3 -m test with python 3.14.2 (and 3.14.1) with this traceback:

Click to view
0:18:03 load avg: 0.84 [387/491] test_struct
Exception in initializer:
Traceback (most recent call last):
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/interpreters/_crossinterp.py", line 88, in serialize_unbound
    flag = _UNBOUND_CONSTANT_TO_FLAG[op]
           ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
KeyError: concurrent.interpreters._queues.UNBOUND

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/futures/thread.py", line 99, in _worker
    ctx.initialize()
    ~~~~~~~~~~~~~~^^
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/futures/interpreter.py", line 64, in initialize
    self.results = interpreters.create_queue(maxsize)
                   ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/interpreters/_queues.py", line 75, in create
    unbound = _serialize_unbound(unbounditems)
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/interpreters/_queues.py", line 56, in _serialize_unbound
    return _crossinterp.serialize_unbound(unbound)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/interpreters/_crossinterp.py", line 90, in serialize_unbound
    raise NotImplementedError(f'unsupported unbound replacement op {op!r}')
NotImplementedError: unsupported unbound replacement op concurrent.interpreters._queues.UNBOUND
Exception in initializer:
Traceback (most recent call last):
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/interpreters/_crossinterp.py", line 88, in serialize_unbound
    flag = _UNBOUND_CONSTANT_TO_FLAG[op]
           ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
KeyError: concurrent.interpreters._queues.UNBOUND

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/futures/thread.py", line 99, in _worker
    ctx.initialize()
    ~~~~~~~~~~~~~~^^
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/futures/interpreter.py", line 64, in initialize
    self.results = interpreters.create_queue(maxsize)
                   ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/interpreters/_queues.py", line 75, in create
    unbound = _serialize_unbound(unbounditems)
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/interpreters/_queues.py", line 56, in _serialize_unbound
    return _crossinterp.serialize_unbound(unbound)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/interpreters/_crossinterp.py", line 90, in serialize_unbound
    raise NotImplementedError(f'unsupported unbound replacement op {op!r}')
NotImplementedError: unsupported unbound replacement op concurrent.interpreters._queues.UNBOUND
Exception in initializer:
Traceback (most recent call last):
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/interpreters/_crossinterp.py", line 88, in serialize_unbound
    flag = _UNBOUND_CONSTANT_TO_FLAG[op]
           ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
KeyError: concurrent.interpreters._queues.UNBOUND

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/futures/thread.py", line 99, in _worker
    ctx.initialize()
    ~~~~~~~~~~~~~~^^
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/futures/interpreter.py", line 64, in initialize
    self.results = interpreters.create_queue(maxsize)
                   ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/interpreters/_queues.py", line 75, in create
    unbound = _serialize_unbound(unbounditems)
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/interpreters/_queues.py", line 56, in _serialize_unbound
    return _crossinterp.serialize_unbound(unbound)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/interpreters/_crossinterp.py", line 90, in serialize_unbound
    raise NotImplementedError(f'unsupported unbound replacement op {op!r}')
NotImplementedError: unsupported unbound replacement op concurrent.interpreters._queues.UNBOUND
Exception in initializer:
Traceback (most recent call last):
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/interpreters/_crossinterp.py", line 88, in serialize_unbound
    flag = _UNBOUND_CONSTANT_TO_FLAG[op]
           ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
KeyError: concurrent.interpreters._queues.UNBOUND

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/futures/thread.py", line 99, in _worker
    ctx.initialize()
    ~~~~~~~~~~~~~~^^
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/futures/interpreter.py", line 64, in initialize
    self.results = interpreters.create_queue(maxsize)
                   ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/interpreters/_queues.py", line 75, in create
    unbound = _serialize_unbound(unbounditems)
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/interpreters/_queues.py", line 56, in _serialize_unbound
    return _crossinterp.serialize_unbound(unbound)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/interpreters/_crossinterp.py", line 90, in serialize_unbound
    raise NotImplementedError(f'unsupported unbound replacement op {op!r}')
NotImplementedError: unsupported unbound replacement op concurrent.interpreters._queues.UNBOUND
Exception in initializer:
Traceback (most recent call last):
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/interpreters/_crossinterp.py", line 88, in serialize_unbound
    flag = _UNBOUND_CONSTANT_TO_FLAG[op]
           ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
KeyError: concurrent.interpreters._queues.UNBOUND

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/futures/thread.py", line 99, in _worker
    ctx.initialize()
    ~~~~~~~~~~~~~~^^
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/futures/interpreter.py", line 64, in initialize
    self.results = interpreters.create_queue(maxsize)
                   ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/interpreters/_queues.py", line 75, in create
    unbound = _serialize_unbound(unbounditems)
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/interpreters/_queues.py", line 56, in _serialize_unbound
    return _crossinterp.serialize_unbound(unbound)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/interpreters/_crossinterp.py", line 90, in serialize_unbound
    raise NotImplementedError(f'unsupported unbound replacement op {op!r}')
NotImplementedError: unsupported unbound replacement op concurrent.interpreters._queues.UNBOUND
test test_struct failed -- Traceback (most recent call last):
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/test/test_struct.py", line 818, in test_endian_table_init_subinterpreters
    self.assertListEqual(list(results), [None] * 5)
                         ~~~~^^^^^^^^^
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/futures/_base.py", line 639, in result_iterator
    yield _result_or_cancel(fs.pop())
          ~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/futures/_base.py", line 311, in _result_or_cancel
    return fut.result(timeout)
           ~~~~~~~~~~^^^^^^^^^
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/futures/_base.py", line 450, in result
    return self.__get_result()
           ~~~~~~~~~~~~~~~~~^^
  File "/home/usr00/.pyenv/versions/3.14.2/lib/python3.14/concurrent/futures/_base.py", line 395, in __get_result
    raise self._exception
concurrent.futures.interpreter.BrokenInterpreterPool: A thread initializer failed, the thread pool is not usable anymore

0:18:04 load avg: 0.84 [387/491/1] test_struct failed (1 error)

Tested on Ubuntu 24.04 (gcc 14.2.0 - clang 21.1.8) and Ubuntu 20.04 (gcc 11.4.0), several CPUs.

python 3.14.0 and 3.13.x, bult in the same way, pass smoothly python3 -m test

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Linked PRs

Activity

  1. ppigazzini commented on Dec 10, 2025

    @ppigazzini
    Author

    In my tests this is sufficient to trigger the bug.
    python3 -m test test_interpreters test_struct

  2. changed the title [-]`test_struct` fails for python 3.14.2 built with gcc/clang[/-] [+]`./python -m test test_interpreters test_struct` fails with: KeyError: concurrent.interpreters._queues.UNBOUND[/+] on Dec 10, 2025
  3. vstinner commented on Dec 10, 2025

    @vstinner
    Member

    This command is enough to trigger the issue:

    $ cat bisect 
    test.test_struct.StructTest.test_endian_table_init_subinterpreters
    test.test_interpreters.test_queues.LowLevelTests.test_highlevel_reloaded
    
    $ ./python -m test test_interpreters test_struct --matchfile=bisect
    

    Short reproducer:

    import importlib
    import unittest
    from concurrent.interpreters import _queues as queues
    
    class Tests(unittest.TestCase):
        def test_step1(self):
            importlib.reload(queues)
    
        def test_step2(self):
            from concurrent.futures import InterpreterPoolExecutor
    
            code = "import struct"
            with InterpreterPoolExecutor(max_workers=1) as executor:
                results = executor.map(exec, [code] * 1)
                self.assertListEqual(list(results), [None] * 1)
    
    if __name__ == "__main__":
        unittest.main()

    where step 1 comes from test_highlevel_reloaded() which is related to the issue #115490.

  4. vstinner commented on Dec 10, 2025

    @vstinner
    Member
  5. vstinner commented on Dec 10, 2025

    @vstinner
    Member

    I mark this issue as a release blocker since the release script runs tests sequentially.

  6. gkirchou commented on Dec 10, 2025

    @gkirchou
    Contributor

    Hitting this too while runing ./python Lib/test/test_runpy.py. (Thanks for OP to narrow down this to ./python -m test test_interpreters test_struct, I had a hard time to repro this in my end...)

    I made a PR to fix this, not sure if the right fix though.

  7. ZeroIntensity commented on Dec 10, 2025

    @ZeroIntensity
    Member

    I think the root of the problem lies in the fact that we're doing some hacky things to implement a singleton for UNBOUND:

    @classonly
    def singleton(cls, kind, module, name='UNBOUND'):
    doc = cls.__doc__
    if doc:
    doc = doc.replace(
    'cross-interpreter container', kind,
    ).replace(
    'cross-interpreter', kind,
    )
    subclass = type(
    f'Unbound{kind.capitalize()}Item',
    (cls,),
    {
    "_MODULE": module,
    "_NAME": name,
    "__doc__": doc,
    },
    )
    return object.__new__(subclass)

    As this issue shows, these shenanigans are fragile. Ned has a great article on why singletons aren't a great idea in Python: Singleton is a bad idea. That article seems to apply here, so I'm in favor of eliminating singleton enforcement entirely (and just defining UNBOUND as an object(), which would fix the problem), but I'm not one to make Eric's decisions for him.

  8. note35 commented on Dec 11, 2025

    @note35
    Contributor

    I also made one more PR based on the idea to remove singleton. I am worried that this one may change the original code's intention, thus I made 2 PR instead of 1. Please pick up the preferred one to continue the discussion, thanks!

  9. note35 commented on Dec 11, 2025

    @note35
    Contributor

    I just found another case that stops working (running forever) after the attempted fixes:

    ./python -m test test_interpreters test_concurrent_futures.test_interpreter_pool 
    

    [Update] I managed to find a solution by just fixing the test + making the singleton object picklable.

  10. hugovk commented on Dec 13, 2025

    @hugovk
    Member

    I mark this issue as a release blocker since the release script runs tests sequentially.

    Not any more, since python/release-tools#304.

  11. Allactaga commented on Jan 21, 2026

    @Allactaga
    Contributor

    Hey, folks. Thank you for troubleshooting the problem and narrowing it down. Since it's been a while and I am hitting the same issue, I took a crack at looking at the code. The singleton is a red herring. It's actually not even a singleton. 🙂

    The issue is with reloading the single module in tests while other modules, that have already imported the variables, keeping the old references. This breaks identity checks, dictionary key lookups, and exception handling. Luckily isolating importlib.reload inside a subinterpreter seems to work, so I hope this means we can resolve this.

  12. ppigazzini commented on Feb 3, 2026

    @ppigazzini
    Author

    test_struct still fails with the same error in the new python 3.14.3 for all my builds (Ubuntu 22.04 and 24.04, gcc and clang).

    Click to view

    0:15:32 load avg: 0.80 [386/492] test_strtod
    0:15:33 load avg: 0.80 [386/492] test_strtod passed
    0:15:33 load avg: 0.80 [387/492] test_struct
    Exception in initializer:
    Traceback (most recent call last):
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/interpreters/_crossinterp.py", line 88, in serialize_unbound
    flag = _UNBOUND_CONSTANT_TO_FLAG[op]
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
    KeyError: concurrent.interpreters._queues.UNBOUND

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/futures/thread.py", line 99, in _worker
    ctx.initialize()
    ~~~~~~~~~~~~~~^^
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/futures/interpreter.py", line 64, in initialize
    self.results = interpreters.create_queue(maxsize)
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/interpreters/_queues.py", line 75, in create
    unbound = _serialize_unbound(unbounditems)
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/interpreters/_queues.py", line 56, in _serialize_unbound
    return _crossinterp.serialize_unbound(unbound)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/interpreters/_crossinterp.py", line 90, in serialize_unbound
    raise NotImplementedError(f'unsupported unbound replacement op {op!r}')
    NotImplementedError: unsupported unbound replacement op concurrent.interpreters._queues.UNBOUND
    Exception in initializer:
    Traceback (most recent call last):
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/interpreters/_crossinterp.py", line 88, in serialize_unbound
    flag = _UNBOUND_CONSTANT_TO_FLAG[op]
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
    KeyError: concurrent.interpreters._queues.UNBOUND

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/futures/thread.py", line 99, in _worker
    ctx.initialize()
    ~~~~~~~~~~~~~~^^
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/futures/interpreter.py", line 64, in initialize
    self.results = interpreters.create_queue(maxsize)
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/interpreters/_queues.py", line 75, in create
    unbound = _serialize_unbound(unbounditems)
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/interpreters/_queues.py", line 56, in _serialize_unbound
    return _crossinterp.serialize_unbound(unbound)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/interpreters/_crossinterp.py", line 90, in serialize_unbound
    raise NotImplementedError(f'unsupported unbound replacement op {op!r}')
    NotImplementedError: unsupported unbound replacement op concurrent.interpreters._queues.UNBOUND
    Exception in initializer:
    Traceback (most recent call last):
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/interpreters/_crossinterp.py", line 88, in serialize_unbound
    flag = _UNBOUND_CONSTANT_TO_FLAG[op]
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
    KeyError: concurrent.interpreters._queues.UNBOUND

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/futures/thread.py", line 99, in _worker
    ctx.initialize()
    ~~~~~~~~~~~~~~^^
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/futures/interpreter.py", line 64, in initialize
    self.results = interpreters.create_queue(maxsize)
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/interpreters/_queues.py", line 75, in create
    unbound = _serialize_unbound(unbounditems)
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/interpreters/_queues.py", line 56, in _serialize_unbound
    return _crossinterp.serialize_unbound(unbound)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/interpreters/_crossinterp.py", line 90, in serialize_unbound
    raise NotImplementedError(f'unsupported unbound replacement op {op!r}')
    NotImplementedError: unsupported unbound replacement op concurrent.interpreters._queues.UNBOUND
    Exception in initializer:
    Traceback (most recent call last):
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/interpreters/_crossinterp.py", line 88, in serialize_unbound
    flag = _UNBOUND_CONSTANT_TO_FLAG[op]
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
    KeyError: concurrent.interpreters._queues.UNBOUND

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/futures/thread.py", line 99, in _worker
    ctx.initialize()
    ~~~~~~~~~~~~~~^^
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/futures/interpreter.py", line 64, in initialize
    self.results = interpreters.create_queue(maxsize)
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/interpreters/_queues.py", line 75, in create
    unbound = _serialize_unbound(unbounditems)
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/interpreters/_queues.py", line 56, in _serialize_unbound
    return _crossinterp.serialize_unbound(unbound)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/interpreters/_crossinterp.py", line 90, in serialize_unbound
    raise NotImplementedError(f'unsupported unbound replacement op {op!r}')
    NotImplementedError: unsupported unbound replacement op concurrent.interpreters._queues.UNBOUND
    Exception in initializer:
    Traceback (most recent call last):
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/interpreters/_crossinterp.py", line 88, in serialize_unbound
    flag = _UNBOUND_CONSTANT_TO_FLAG[op]
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
    KeyError: concurrent.interpreters._queues.UNBOUND

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/futures/thread.py", line 99, in _worker
    ctx.initialize()
    ~~~~~~~~~~~~~~^^
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/futures/interpreter.py", line 64, in initialize
    self.results = interpreters.create_queue(maxsize)
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/interpreters/_queues.py", line 75, in create
    unbound = _serialize_unbound(unbounditems)
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/interpreters/_queues.py", line 56, in _serialize_unbound
    return _crossinterp.serialize_unbound(unbound)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/interpreters/_crossinterp.py", line 90, in serialize_unbound
    raise NotImplementedError(f'unsupported unbound replacement op {op!r}')
    NotImplementedError: unsupported unbound replacement op concurrent.interpreters._queues.UNBOUND
    test test_struct failed -- Traceback (most recent call last):
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/test/test_struct.py", line 824, in test_endian_table_init_subinterpreters
    self.assertListEqual(list(results), [None] * 5)
    ~~~~^^^^^^^^^
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/futures/_base.py", line 639, in result_iterator
    yield _result_or_cancel(fs.pop())
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/futures/_base.py", line 311, in _result_or_cancel
    return fut.result(timeout)
    ~~~~~~~~~~^^^^^^^^^
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/futures/_base.py", line 450, in result
    return self.__get_result()
    ~~~~~~~~~~~~~~~~~^^
    File "/home/usr00/.pyenv/versions/3.14.3/lib/python3.14/concurrent/futures/_base.py", line 395, in __get_result
    raise self._exception
    concurrent.futures.interpreter.BrokenInterpreterPool: A thread initializer failed, the thread pool is not usable anymore

    0:15:33 load avg: 0.80 [387/492/1] test_struct failed (1 error)
    0:15:33 load avg: 0.80 [388/492/1] test_structseq
    0:15:34 load avg: 0.80 [388/492/1] test_structseq passed

  13. Allactaga commented on Feb 4, 2026

    @Allactaga
    Contributor

    Hey, @ppigazzini, while Core team is looking for the fix, I think the approach I suggested in gh-144096 could be used as a quick relief. You can temporarily hot patch with:
    git fetch origin --depth 2 9208c1d95b194f3cea595251ca1b2b9d267b09cf && git show 9208c1d95b194f3cea595251ca1b2b9d267b09cf | git apply

    Or just ignore while running tests: ./python -m test test_interpreters test_struct -i test.test_interpreters.test_queues.LowLevelTests.test_highlevel_reloaded -i test.test_interpreters.test_channels.LowLevelTests.test_highlevel_reloaded

  14. Allactaga commented on Feb 21, 2026

    @Allactaga
    Contributor

    Gentle ping for review on the linked PR #144096: it isolates the module-reload side-effect causing the test_struct flake in this issue.

    Change is minimal/safe. No runtime impact, just ensures that importlib.reload in tests doesn't pollute the rest of the suite. It preserves the original test intent from #115493.

    This helps test-suite reliability (including PGO builds). CI green, merges cleanly.

    @ericsnowcurrently (and anyone else interested), would appreciate a look when you can. Thanks!

  15. added a commit that references this issue on Feb 24, 2026
  16. ashm-dev commented on Mar 18, 2026

    @ashm-dev
    Contributor

    I'm having the same problem in the main branch. I built it like this:
    CC=gcc CXX=g++ ./configure

    boss@oops-lab ~/projects/oss/cpython/main (main %2⚑1)
    $ gcc -v
    Using built-in specs.
    COLLECT_GCC=gcc
    COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/lto-wrapper
    Target: x86_64-pc-linux-gnu
    Configured with: /build/gcc/src/gcc/configure --enable-languages=ada,c,c++,d,fortran,go,lto,m2,objc,obj-c++,rust,cobol --enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://gitlab.archlinux.org/archlinux/packaging/packages/gcc/-/issues --with-build-config=bootstrap-lto --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-libstdcxx-backtrace --enable-link-serialization=1 --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-werror
    Thread model: posix
    Supported LTO compression algorithms: zlib zstd
    gcc version 15.2.1 20260209 (GCC)
    
    logs

    0:30:25 load avg: 5.09 [397/501/4] test_struct
    Exception in initializer:
    Traceback (most recent call last):
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/interpreters/_crossinterp.py", line 88, in serialize_unbound
        flag = _UNBOUND_CONSTANT_TO_FLAG[op]
               ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
    KeyError: concurrent.interpreters._queues.UNBOUND
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/futures/thread.py", line 99, in _worker
        ctx.initialize()
        ~~~~~~~~~~~~~~^^
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/futures/interpreter.py", line 64, in initialize
        self.results = interpreters.create_queue(maxsize)
                       ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/interpreters/_queues.py", line 74, in create
        unbound = _serialize_unbound(unbounditems)
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/interpreters/_queues.py", line 55, in _serialize_unbound
        return _crossinterp.serialize_unbound(unbound)
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/interpreters/_crossinterp.py", line 90, in serialize_unbound
        raise NotImplementedError(f'unsupported unbound replacement op {op!r}')
    NotImplementedError: unsupported unbound replacement op concurrent.interpreters._queues.UNBOUND
    Exception in initializer:
    Traceback (most recent call last):
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/interpreters/_crossinterp.py", line 88, in serialize_unbound
        flag = _UNBOUND_CONSTANT_TO_FLAG[op]
               ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
    KeyError: concurrent.interpreters._queues.UNBOUND
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/futures/thread.py", line 99, in _worker
        ctx.initialize()
        ~~~~~~~~~~~~~~^^
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/futures/interpreter.py", line 64, in initialize
        self.results = interpreters.create_queue(maxsize)
                       ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/interpreters/_queues.py", line 74, in create
        unbound = _serialize_unbound(unbounditems)
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/interpreters/_queues.py", line 55, in _serialize_unbound
        return _crossinterp.serialize_unbound(unbound)
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/interpreters/_crossinterp.py", line 90, in serialize_unbound
        raise NotImplementedError(f'unsupported unbound replacement op {op!r}')
    NotImplementedError: unsupported unbound replacement op concurrent.interpreters._queues.UNBOUND
    Exception in initializer:
    Traceback (most recent call last):
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/interpreters/_crossinterp.py", line 88, in serialize_unbound
        flag = _UNBOUND_CONSTANT_TO_FLAG[op]
               ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
    KeyError: concurrent.interpreters._queues.UNBOUND
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/futures/thread.py", line 99, in _worker
        ctx.initialize()
        ~~~~~~~~~~~~~~^^
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/futures/interpreter.py", line 64, in initialize
        self.results = interpreters.create_queue(maxsize)
                       ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/interpreters/_queues.py", line 74, in create
        unbound = _serialize_unbound(unbounditems)
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/interpreters/_queues.py", line 55, in _serialize_unbound
        return _crossinterp.serialize_unbound(unbound)
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/interpreters/_crossinterp.py", line 90, in serialize_unbound
        raise NotImplementedError(f'unsupported unbound replacement op {op!r}')
    NotImplementedError: unsupported unbound replacement op concurrent.interpreters._queues.UNBOUND
    Exception in initializer:
    Traceback (most recent call last):
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/interpreters/_crossinterp.py", line 88, in serialize_unbound
        flag = _UNBOUND_CONSTANT_TO_FLAG[op]
               ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
    KeyError: concurrent.interpreters._queues.UNBOUND
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/futures/thread.py", line 99, in _worker
        ctx.initialize()
        ~~~~~~~~~~~~~~^^
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/futures/interpreter.py", line 64, in initialize
        self.results = interpreters.create_queue(maxsize)
                       ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/interpreters/_queues.py", line 74, in create
        unbound = _serialize_unbound(unbounditems)
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/interpreters/_queues.py", line 55, in _serialize_unbound
        return _crossinterp.serialize_unbound(unbound)
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/interpreters/_crossinterp.py", line 90, in serialize_unbound
        raise NotImplementedError(f'unsupported unbound replacement op {op!r}')
    NotImplementedError: unsupported unbound replacement op concurrent.interpreters._queues.UNBOUND
    Exception in initializer:
    Traceback (most recent call last):
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/interpreters/_crossinterp.py", line 88, in serialize_unbound
        flag = _UNBOUND_CONSTANT_TO_FLAG[op]
               ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
    KeyError: concurrent.interpreters._queues.UNBOUND
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/futures/thread.py", line 99, in _worker
        ctx.initialize()
        ~~~~~~~~~~~~~~^^
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/futures/interpreter.py", line 64, in initialize
        self.results = interpreters.create_queue(maxsize)
                       ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/interpreters/_queues.py", line 74, in create
        unbound = _serialize_unbound(unbounditems)
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/interpreters/_queues.py", line 55, in _serialize_unbound
        return _crossinterp.serialize_unbound(unbound)
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/interpreters/_crossinterp.py", line 90, in serialize_unbound
        raise NotImplementedError(f'unsupported unbound replacement op {op!r}')
    NotImplementedError: unsupported unbound replacement op concurrent.interpreters._queues.UNBOUND
    test test_struct failed -- Traceback (most recent call last):
      File "/home/boss/projects/oss/cpython/main/Lib/test/test_struct.py", line 1003, in test_endian_table_init_subinterpreters
        self.assertListEqual(list(results), [None] * 5)
                             ~~~~^^^^^^^^^
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/futures/_base.py", line 666, in result_iterator
        yield _result_or_cancel(fs.pop())
              ~~~~~~~~~~~~~~~~~^^^^^^^^^^
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/futures/_base.py", line 311, in _result_or_cancel
        return fut.result(timeout)
               ~~~~~~~~~~^^^^^^^^^
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/futures/_base.py", line 450, in result
        return self.__get_result()
               ~~~~~~~~~~~~~~~~~^^
      File "/home/boss/projects/oss/cpython/main/Lib/concurrent/futures/_base.py", line 395, in __get_result
        raise self._exception
    concurrent.futures.interpreter.BrokenInterpreterPool: A thread initializer failed, the thread pool is not usable anymore
    
    0:30:27 load avg: 5.09 [397/501/5] test_struct failed (1 error)
    

  17. added 2 commits that reference this issue on Aug 30, 2026
  18. kesara commented on Aug 30, 2026

    @kesara

    FWIW I was able to produce the same issue on macOS with /python.exe -m test.
    But changes from aa24c20 from seems to fixed it.

    $ gcc -v
    Apple clang version 21.0.0 (clang-2100.1.1.101)
    Target: arm64-apple-darwin25.6.0
    Thread model: posix
    InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
    
  19. ncoghlan commented on Aug 30, 2026

    @ncoghlan
    Contributor

    I merged the #144096 change to avoid side effects from the test cases that check that the _interpreters extension module tolerates the pure Python modules being reloaded.

    Beyond that, our policy on module reloading is generally "If you hot reload a module without cleaning up everything that references it, you get to keep all the shiny pieces when it inevitably breaks". On those grounds, #142515 and #142577 would be closed as "don't do that" (where "that" is reloading concurrent.interpreters submodules without also reloading concurrent.interpreters itself to update the exported API objects).

    However, having the two different UNBOUND singletons seems genuinely odd, so there may still be some genuine code cleanup worth implementing here.

  20. ncoghlan commented on Aug 30, 2026

    @ncoghlan
    Contributor

    Cleanup proposals can go in a separate issue that explains the benefits separately from this test failure (since the modified testing means we won't be hitting that anymore)

  21. added a commit that references this issue on Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions