forked from pool/python-stopit
Add python-stopit-ulong-for-thread-id.patch: Use ulong for thread id on Python >= 3.7, upstream commit dda4bd1 (gh#glenfant/stopit#31).
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-stopit?expand=0&rev=2
This commit is contained in:
47
python-stopit-ulong-for-thread-id.patch
Normal file
47
python-stopit-ulong-for-thread-id.patch
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
From 0da7f4fb26b25e5ed1d35dbce43e2e8bc4ca494a Mon Sep 17 00:00:00 2001
|
||||||
|
From: Antti Kajander <kajaste@users.noreply.github.com>
|
||||||
|
Date: Sat, 18 Nov 2023 02:02:38 +0200
|
||||||
|
Subject: [PATCH] Use ulong for thread id on Python >= 3.7
|
||||||
|
|
||||||
|
As per https://docs.python.org/3/c-api/init.html#c.PyThreadState_SetAsyncExc
|
||||||
|
---
|
||||||
|
src/stopit/threadstop.py | 10 ++++++++--
|
||||||
|
1 file changed, 8 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/stopit/threadstop.py b/src/stopit/threadstop.py
|
||||||
|
index 37ecb92..a991750 100644
|
||||||
|
--- a/src/stopit/threadstop.py
|
||||||
|
+++ b/src/stopit/threadstop.py
|
||||||
|
@@ -9,10 +9,16 @@
|
||||||
|
"""
|
||||||
|
|
||||||
|
import ctypes
|
||||||
|
+import sys
|
||||||
|
import threading
|
||||||
|
|
||||||
|
from .utils import TimeoutException, BaseTimeout, base_timeoutable
|
||||||
|
|
||||||
|
+if sys.version_info < (3, 7):
|
||||||
|
+ tid_ctype = ctypes.c_long
|
||||||
|
+else:
|
||||||
|
+ tid_ctype = ctypes.c_ulong
|
||||||
|
+
|
||||||
|
|
||||||
|
def async_raise(target_tid, exception):
|
||||||
|
"""Raises an asynchronous exception in another thread.
|
||||||
|
@@ -24,13 +30,13 @@ def async_raise(target_tid, exception):
|
||||||
|
"""
|
||||||
|
# Ensuring and releasing GIL are useless since we're not in C
|
||||||
|
# gil_state = ctypes.pythonapi.PyGILState_Ensure()
|
||||||
|
- ret = ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(target_tid),
|
||||||
|
+ ret = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid_ctype(target_tid),
|
||||||
|
ctypes.py_object(exception))
|
||||||
|
# ctypes.pythonapi.PyGILState_Release(gil_state)
|
||||||
|
if ret == 0:
|
||||||
|
raise ValueError("Invalid thread ID {}".format(target_tid))
|
||||||
|
elif ret > 1:
|
||||||
|
- ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(target_tid), None)
|
||||||
|
+ ctypes.pythonapi.PyThreadState_SetAsyncExc(tid_ctype(target_tid), None)
|
||||||
|
raise SystemError("PyThreadState_SetAsyncExc failed")
|
||||||
|
|
||||||
|
|
@@ -1,3 +1,10 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Tue Feb 4 15:44:08 UTC 2025 - Atri Bhattacharya <badshah400@gmail.com>
|
||||||
|
|
||||||
|
- Add python-stopit-ulong-for-thread-id.patch: Use ulong for
|
||||||
|
thread id on Python >= 3.7, upstream commit dda4bd1
|
||||||
|
(gh#glenfant/stopit#31).
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Tue Feb 4 11:50:34 UTC 2025 - Atri Bhattacharya <badshah400@gmail.com>
|
Tue Feb 4 11:50:34 UTC 2025 - Atri Bhattacharya <badshah400@gmail.com>
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# spec file for package python-stopit
|
# spec file for package python-stopit
|
||||||
#
|
#
|
||||||
# Copyright (c) 2025 SUSE LINUX GmbH, Nuernberg, Germany.
|
# Copyright (c) 2025 SUSE LLC
|
||||||
#
|
#
|
||||||
# All modifications and additions to the file contributed by third parties
|
# All modifications and additions to the file contributed by third parties
|
||||||
# remain the property of their copyright owners, unless otherwise agreed
|
# remain the property of their copyright owners, unless otherwise agreed
|
||||||
@@ -12,7 +12,8 @@
|
|||||||
# license that conforms to the Open Source Definition (Version 1.9)
|
# license that conforms to the Open Source Definition (Version 1.9)
|
||||||
# published by the Open Source Initiative.
|
# published by the Open Source Initiative.
|
||||||
|
|
||||||
# Please submit bugfixes or comments via http://bugs.opensuse.org/
|
# Please submit bugfixes or comments via https://bugs.opensuse.org/
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
%define modname stopit
|
%define modname stopit
|
||||||
@@ -25,6 +26,8 @@ URL: https://pypi.python.org/pypi/stopit
|
|||||||
Source0: https://files.pythonhosted.org/packages/source/s/stopit/stopit-%{version}.tar.gz
|
Source0: https://files.pythonhosted.org/packages/source/s/stopit/stopit-%{version}.tar.gz
|
||||||
Source1: https://raw.githubusercontent.com/glenfant/stopit/refs/tags/%{version}/tests.py
|
Source1: https://raw.githubusercontent.com/glenfant/stopit/refs/tags/%{version}/tests.py
|
||||||
Source2: https://raw.githubusercontent.com/glenfant/stopit/refs/tags/%{version}/LICENSE
|
Source2: https://raw.githubusercontent.com/glenfant/stopit/refs/tags/%{version}/LICENSE
|
||||||
|
# PATCH-FIX-UPSTREAM
|
||||||
|
Patch0: https://github.com/glenfant/stopit/commit/dda4bd181d1d29ab1fb22314dc9bde0e3c931abc.patch#/python-stopit-ulong-for-thread-id.patch
|
||||||
BuildRequires: %{python_module devel}
|
BuildRequires: %{python_module devel}
|
||||||
BuildRequires: %{python_module pip}
|
BuildRequires: %{python_module pip}
|
||||||
BuildRequires: %{python_module setuptools}
|
BuildRequires: %{python_module setuptools}
|
||||||
@@ -41,7 +44,7 @@ BuildArch: noarch
|
|||||||
* two decorators that may stop its decorated callables on timeout.
|
* two decorators that may stop its decorated callables on timeout.
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%autosetup -n %{modname}-%{version}
|
%autosetup -p1 -n %{modname}-%{version}
|
||||||
cp %{SOURCE1} %{SOURCE2} ./
|
cp %{SOURCE1} %{SOURCE2} ./
|
||||||
|
|
||||||
%build
|
%build
|
||||||
|
Reference in New Issue
Block a user