-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Closed as not planned
Closed as not planned
Copy link
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
Context:
./python -m test test_interpreters test_structfails with: KeyError: concurrent.interpreters._queues.UNBOUND #142414 (comment)- gh-142414: Unify UNBOUND in Lib/concurrent/interpreters/_queues.py and Lib/concurrent/interpreters/_crossinterp.py. #142515 should fix the issue found in
./python -m test test_interpreters test_structfails with: KeyError: concurrent.interpreters._queues.UNBOUND #142414.
And during the time I was exploring the singleton removal, I found out it's possible, but the test may miss an edge case:
from concurrent import interpreters
from concurrent.interpreters import _queues as queues
import unittest
class Tests(unittest.TestCase):
def test_cross_interpreter_unbound_identity(self):
# Prepare shared queues.
input_q = interpreters.create_queue()
input_q.put(queues.UNBOUND)
result_q = interpreters.create_queue()
# Create a sub-interpreter.
interp = interpreters.create()
interp.prepare_main({"input_q": input_q, "result_q": result_q})
# Run and compare the items in queue.
interp.exec("""
from concurrent.interpreters import _queues as queues
obj = input_q.get()
is_identical = (obj is queues.UNBOUND)
result_q.put(is_identical)
""")
is_identical = result_q.get()
self.assertTrue(is_identical, "UNBOUND identity mismatch across interpreters")
if __name__ == "__main__":
unittest.main()This test is failed without making the object picklable:
ERROR: test_cross_interpreter_unbound_identity (__main__.Tests.test_cross_interpreter_unbound_identity)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/google/home/kirchou/lamdef/cpython/Lib/test/test_addd.py", line 17, in test_cross_interpreter_unbound_identity
interp.exec("""
~~~~~~~~~~~^^^^
from concurrent.interpreters import _queues as queues
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<2 lines>...
result_q.put(is_identical)
^^^^^^^^^^^^^^^^^^^^^^^^^^
""")
^^^^
File "/usr/local/google/home/kirchou/lamdef/cpython/Lib/concurrent/interpreters/__init__.py", line 217, in exec
raise ExecutionFailed(excinfo)
concurrent.interpreters.ExecutionFailed: concurrent.interpreters.NotShareableError: object could not be unpickled
Uncaught in the interpreter:
Traceback (most recent call last):
File "/usr/local/google/home/kirchou/lamdef/cpython/Lib/concurrent/interpreters/_crossinterp.py", line 65, in __new__
raise Exception(f'use {cls._MODULE}.{cls._NAME}')
Exception: use concurrent.interpreters._crossinterp.UNBOUND
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<script>", line 3, in <module>
File "/usr/local/google/home/kirchou/lamdef/cpython/Lib/concurrent/interpreters/_queues.py", line 261, in get
obj, unboundop = _queues.get(self._id)
~~~~~~~~~~~^^^^^^^^^^
concurrent.interpreters.NotShareableError: object could not be unpickled
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Metadata
Metadata
Assignees
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error