15
0

- Add patch 0001-Use-SO_REUSEPORT-only-for-AF_INET-sockets.patch to

make it compatible with latest cpython. gh#Thriftpy/thriftpy2#303
- Update to 0.5.2:
  * Fix an issue where loading a thrift file in a sub-thread will cause an error with load_fp.
  * Move static metadata from setup.py to pyproject.toml.
  * Using a thread pool to avoid TAsyncSocket.open block the event loop.
- 0.5.1:
  * Fix an issue where loading a thrift file in a sub-thread will cause an error.
  * Some typo fixes.

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-thriftpy2?expand=0&rev=26
This commit is contained in:
2025-02-26 12:07:51 +00:00
committed by Git OBS Bridge
parent 392779d868
commit d299e6cce3
5 changed files with 73 additions and 8 deletions

View File

@@ -0,0 +1,47 @@
From 6590305637da64e0b1898bbb2ecd9700aef7c06b Mon Sep 17 00:00:00 2001
From: Daniel Garcia Moreno <daniel.garcia@suse.com>
Date: Wed, 26 Feb 2025 13:00:45 +0100
Subject: [PATCH] Use SO_REUSEPORT only for AF_INET sockets
The latest python version changes the behavior, now if it's used with
other kind of sockets (ex AF_UNIX) it raises OSError:
https://github.com/python/cpython/issues/128916
---
thriftpy2/contrib/aio/socket.py | 4 +++-
thriftpy2/transport/socket.py | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/thriftpy2/contrib/aio/socket.py b/thriftpy2/contrib/aio/socket.py
index 8f4195a..28b0cc8 100644
--- a/thriftpy2/contrib/aio/socket.py
+++ b/thriftpy2/contrib/aio/socket.py
@@ -281,7 +281,9 @@ class TAsyncServerSocket(object):
_sock = socket.socket(self.socket_family, socket.SOCK_STREAM)
_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
- if hasattr(socket, "SO_REUSEPORT"):
+ # valid socket https://github.com/python/cpython/issues/128916
+ valid_family = (socket.AF_INET, socket.AF_INET6)
+ if _sock.family in valid_family and hasattr(socket, "SO_REUSEPORT"):
try:
_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
except socket.error as err:
diff --git a/thriftpy2/transport/socket.py b/thriftpy2/transport/socket.py
index edd78ab..b98b4c8 100644
--- a/thriftpy2/transport/socket.py
+++ b/thriftpy2/transport/socket.py
@@ -201,7 +201,9 @@ class TServerSocket(object):
_sock = socket.socket(self.socket_family, socket.SOCK_STREAM)
_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
- if hasattr(socket, "SO_REUSEPORT"):
+ # valid socket https://github.com/python/cpython/issues/128916
+ valid_family = (socket.AF_INET, socket.AF_INET6)
+ if _sock.family in valid_family and hasattr(socket, "SO_REUSEPORT"):
try:
_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
except socket.error as err:
--
2.48.0

View File

@@ -1,3 +1,16 @@
-------------------------------------------------------------------
Wed Feb 26 11:05:48 UTC 2025 - Daniel Garcia <daniel.garcia@suse.com>
- Add patch 0001-Use-SO_REUSEPORT-only-for-AF_INET-sockets.patch to
make it compatible with latest cpython. gh#Thriftpy/thriftpy2#303
- Update to 0.5.2:
* Fix an issue where loading a thrift file in a sub-thread will cause an error with load_fp.
* Move static metadata from setup.py to pyproject.toml.
* Using a thread pool to avoid TAsyncSocket.open block the event loop.
- 0.5.1:
* Fix an issue where loading a thrift file in a sub-thread will cause an error.
* Some typo fixes.
-------------------------------------------------------------------
Wed May 29 11:59:34 UTC 2024 - John Paul Adrian Glaubitz <adrian.glaubitz@suse.com>

View File

@@ -1,7 +1,7 @@
#
# spec file for package python-thriftpy2
#
# Copyright (c) 2024 SUSE LLC
# Copyright (c) 2025 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -18,13 +18,15 @@
%{?sle15_python_module_pythons}
Name: python-thriftpy2
Version: 0.5.0
Version: 0.5.2
Release: 0
Summary: Pure python implementation of Apache Thrift
License: MIT
URL: https://github.com/Thriftpy/thriftpy2
Source0: https://github.com/Thriftpy/thriftpy2/archive/v%{version}.tar.gz
Source1: new_certs.tar.xz
# PATCH-FIX-UPSTREAM 0001-Use-SO_REUSEPORT-only-for-AF_INET-sockets.patch gh#Thriftpy/thriftpy2#303
Patch1: 0001-Use-SO_REUSEPORT-only-for-AF_INET-sockets.patch
BuildRequires: %{python_module Cython}
BuildRequires: %{python_module dbm}
BuildRequires: %{python_module devel}
@@ -38,7 +40,6 @@ BuildRequires: %{python_module tornado >= 5.0}
BuildRequires: %{python_module wheel}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
BuildRequires: python3-pytest-asyncio
Requires: python-ply >= 3.4
Requires: python-six
Recommends: python-tornado >= 5.0
@@ -67,10 +68,14 @@ find %{buildroot}%{$python_sitearch} -name '*.c' -exec rm {} \;
}
%check
cd tests
# the two tests fail in OBS on timeout
# test_asynchronous_exception/test_asynchronous_result - needs old tornado to work
%pytest_arch -k 'not (test_able_to_communicate or test_zero_length_string or test_asynchronous_exception or test_asynchronous_result or test_api_ipv6)'
donttest="test_able_to_communicate or test_zero_length_string or test_asynchronous_exception or test_asynchronous_result or test_api_ipv6"
# Requires python-pytest-reraise
donttest+=" or test_load_in_sub_thread or test_load_fp_in_sub_thread"
cd tests
%pytest_arch -k "not ($donttest)"
%files %{python_files}
%license LICENSE

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0d29754dea98310d1db82e08dd63336dee6bdbed083d6eb408a24323a53983af
size 151115

3
v0.5.2.tar.gz Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:e45429888c0c99ffb2b97af2235acfde0776a2086b3dab7beed04b1601573cc3
size 151685