Nathan Goldbaum created THRIFT-5888:
---------------------------------------
Summary: declare support for free-threaded CPython in extension
modules
Key: THRIFT-5888
URL: https://issues.apache.org/jira/browse/THRIFT-5888
Project: Thrift
Issue Type: Improvement
Components: Python - Library
Affects Versions: 0.22.0
Environment: MacOS 15.5, thrift commit
9cff8b9f5b217c143c75299939c32573ccd4c9c3, Python 3.13.5t built using PyEnv.
Reporter: Nathan Goldbaum
Currently thrift's extensions do not declare support for the free-threaded
build, so if you import them on the free-threaded build you will see a
RuntimeWarning:
{code}
>>> import thrift.protocol.fastbinary
<frozen importlib._bootstrap>:488: RuntimeWarning: The global interpreter lock
(GIL) has been enabled to load module 'thrift.protocol.fastbinary', which has
not declared that it can run safely without the GIL. To override this behavior
and keep the GIL disabled (at your own risk), run with PYTHON_GIL=0 or -Xgil=0.
{code}
If I force-disable the GIL on a free-threaded Python 3.15.5t on my Mac, I don't
see any test failures running the Python tests:
{code}
goldbaum at Nathans-MBP in ~/Documents/thrift/lib/py on master!
± PYTHON_GIL=0 make py3-test
/Users/goldbaum/.pyenv/shims/python setup.py build
running build
running build_py
copying src/__init__.py -> build/lib.macosx-15.5-arm64-cpython-313t/thrift
copying src/TRecursive.py -> build/lib.macosx-15.5-arm64-cpython-313t/thrift
copying src/TTornado.py -> build/lib.macosx-15.5-arm64-cpython-313t/thrift
copying src/TMultiplexedProcessor.py ->
build/lib.macosx-15.5-arm64-cpython-313t/thrift
copying src/Thrift.py -> build/lib.macosx-15.5-arm64-cpython-313t/thrift
copying src/TSCons.py -> build/lib.macosx-15.5-arm64-cpython-313t/thrift
copying src/TSerialization.py -> build/lib.macosx-15.5-arm64-cpython-313t/thrift
copying src/protocol/TProtocolDecorator.py ->
build/lib.macosx-15.5-arm64-cpython-313t/thrift/protocol
copying src/protocol/THeaderProtocol.py ->
build/lib.macosx-15.5-arm64-cpython-313t/thrift/protocol
copying src/protocol/TJSONProtocol.py ->
build/lib.macosx-15.5-arm64-cpython-313t/thrift/protocol
copying src/protocol/TMultiplexedProtocol.py ->
build/lib.macosx-15.5-arm64-cpython-313t/thrift/protocol
copying src/protocol/__init__.py ->
build/lib.macosx-15.5-arm64-cpython-313t/thrift/protocol
copying src/protocol/TBinaryProtocol.py ->
build/lib.macosx-15.5-arm64-cpython-313t/thrift/protocol
copying src/protocol/TBase.py ->
build/lib.macosx-15.5-arm64-cpython-313t/thrift/protocol
copying src/protocol/TCompactProtocol.py ->
build/lib.macosx-15.5-arm64-cpython-313t/thrift/protocol
copying src/protocol/TProtocol.py ->
build/lib.macosx-15.5-arm64-cpython-313t/thrift/protocol
copying src/transport/TTransport.py ->
build/lib.macosx-15.5-arm64-cpython-313t/thrift/transport
copying src/transport/TTwisted.py ->
build/lib.macosx-15.5-arm64-cpython-313t/thrift/transport
copying src/transport/TSSLSocket.py ->
build/lib.macosx-15.5-arm64-cpython-313t/thrift/transport
copying src/transport/__init__.py ->
build/lib.macosx-15.5-arm64-cpython-313t/thrift/transport
copying src/transport/THeaderTransport.py ->
build/lib.macosx-15.5-arm64-cpython-313t/thrift/transport
copying src/transport/TSocket.py ->
build/lib.macosx-15.5-arm64-cpython-313t/thrift/transport
copying src/transport/sslcompat.py ->
build/lib.macosx-15.5-arm64-cpython-313t/thrift/transport
copying src/transport/THttpClient.py ->
build/lib.macosx-15.5-arm64-cpython-313t/thrift/transport
copying src/transport/TZlibTransport.py ->
build/lib.macosx-15.5-arm64-cpython-313t/thrift/transport
copying src/server/__init__.py ->
build/lib.macosx-15.5-arm64-cpython-313t/thrift/server
copying src/server/TServer.py ->
build/lib.macosx-15.5-arm64-cpython-313t/thrift/server
copying src/server/TProcessPoolServer.py ->
build/lib.macosx-15.5-arm64-cpython-313t/thrift/server
copying src/server/THttpServer.py ->
build/lib.macosx-15.5-arm64-cpython-313t/thrift/server
copying src/server/TNonblockingServer.py ->
build/lib.macosx-15.5-arm64-cpython-313t/thrift/server
running build_ext
/Users/goldbaum/.pyenv/shims/python test/thrift_json.py
...
----------------------------------------------------------------------
Ran 3 tests in 0.000s
OK
/Users/goldbaum/.pyenv/shims/python test/thrift_transport.py
...
----------------------------------------------------------------------
Ran 3 tests in 0.001s
OK
/Users/goldbaum/.pyenv/shims/python test/test_sslsocket.py
.sssssssssss
----------------------------------------------------------------------
Ran 12 tests in 0.000s
OK (skipped=11)
/Users/goldbaum/.pyenv/shims/python test/thrift_TBinaryProtocol.py
..
----------------------------------------------------------------------
Ran 2 tests in 0.002s
OK
/Users/goldbaum/.pyenv/shims/python test/thrift_TZlibTransport.py
..
----------------------------------------------------------------------
Ran 2 tests in 1.261s
OK
/Users/goldbaum/.pyenv/shims/python test/thrift_TCompactProtocol.py
.
----------------------------------------------------------------------
Ran 1 test in 0.003s
OK
/Users/goldbaum/.pyenv/shims/python test/thrift_TNonblockingServer.py
-------start server ------
/Users/goldbaum/.pyenv/versions/3.13.5t/lib/python3.13t/threading.py:994:
ResourceWarning: unclosed <socket.socket fd=6, family=2, type=1, proto=0,
laddr=('127.0.0.1', 63805), raddr=('127.0.0.1', 30030)>
self._target(*self._args, **self._kwargs)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
------stop server -----
/Users/goldbaum/.pyenv/versions/3.13.5t/lib/python3.13t/unittest/case.py:606:
ResourceWarning: unclosed <socket.socket fd=3, family=1, type=1, proto=0>
if method() is not None:
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/Users/goldbaum/.pyenv/versions/3.13.5t/lib/python3.13t/unittest/case.py:606:
ResourceWarning: unclosed <socket.socket fd=4, family=1, type=1, proto=0>
if method() is not None:
ResourceWarning: Enable tracemalloc to get the object allocation traceback
.
----------------------------------------------------------------------
Ran 1 test in 10.022s
OK
/Users/goldbaum/.pyenv/shims/python test/thrift_TSerializer.py
....
----------------------------------------------------------------------
Ran 4 tests in 0.001s
OK
{code}
And it looks like the tests do rely on python threads, so this should be
usefully testing concurrent behavior on the free-threaded build.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)