[python] Allow arbitrary timeout in Condition.wait (rhbz#917709).
Bohuslav Kabrda
bkabrda at fedoraproject.org
Mon Apr 22 07:09:47 UTC 2013
commit a31104cb33751911591074037a2e83c9c05b5f08
Author: Bohuslav Kabrda <bkabrda at redhat.com>
Date: Mon Apr 22 09:09:16 2013 +0200
Allow arbitrary timeout in Condition.wait (rhbz#917709).
...allow-arbitrary-timeout-in-condition-wait.patch | 70 ++++++++++++++++++++
python.spec | 14 ++++-
2 files changed, 83 insertions(+), 1 deletions(-)
---
diff --git a/00176-allow-arbitrary-timeout-in-condition-wait.patch b/00176-allow-arbitrary-timeout-in-condition-wait.patch
new file mode 100644
index 0000000..665965d
--- /dev/null
+++ b/00176-allow-arbitrary-timeout-in-condition-wait.patch
@@ -0,0 +1,70 @@
+diff --git a/Lib/threading.py b/Lib/threading.py
+index cb49c4a..c9795a5 100644
+--- a/Lib/threading.py
++++ b/Lib/threading.py
+@@ -305,7 +305,7 @@ class _Condition(_Verbose):
+ else:
+ return True
+
+- def wait(self, timeout=None):
++ def wait(self, timeout=None, balancing=True):
+ """Wait until notified or until a timeout occurs.
+
+ If the calling thread has not acquired the lock when this method is
+@@ -354,7 +354,10 @@ class _Condition(_Verbose):
+ remaining = endtime - _time()
+ if remaining <= 0:
+ break
+- delay = min(delay * 2, remaining, .05)
++ if balancing:
++ delay = min(delay * 2, remaining, 0.05)
++ else:
++ delay = remaining
+ _sleep(delay)
+ if not gotit:
+ if __debug__:
+@@ -599,7 +602,7 @@ class _Event(_Verbose):
+ finally:
+ self.__cond.release()
+
+- def wait(self, timeout=None):
++ def wait(self, timeout=None, balancing=True):
+ """Block until the internal flag is true.
+
+ If the internal flag is true on entry, return immediately. Otherwise,
+@@ -617,7 +620,7 @@ class _Event(_Verbose):
+ self.__cond.acquire()
+ try:
+ if not self.__flag:
+- self.__cond.wait(timeout)
++ self.__cond.wait(timeout, balancing)
+ return self.__flag
+ finally:
+ self.__cond.release()
+@@ -908,7 +911,7 @@ class Thread(_Verbose):
+ if 'dummy_threading' not in _sys.modules:
+ raise
+
+- def join(self, timeout=None):
++ def join(self, timeout=None, balancing=True):
+ """Wait until the thread terminates.
+
+ This blocks the calling thread until the thread whose join() method is
+@@ -957,7 +960,7 @@ class Thread(_Verbose):
+ if __debug__:
+ self._note("%s.join(): timed out", self)
+ break
+- self.__block.wait(delay)
++ self.__block.wait(delay, balancing)
+ else:
+ if __debug__:
+ self._note("%s.join(): thread stopped", self)
+@@ -1143,7 +1146,7 @@ class _DummyThread(Thread):
+ def _set_daemon(self):
+ return True
+
+- def join(self, timeout=None):
++ def join(self, timeout=None, balancing=True):
+ assert False, "cannot join a dummy thread"
+
+
diff --git a/python.spec b/python.spec
index 1c0ab0d..260a29f 100644
--- a/python.spec
+++ b/python.spec
@@ -106,7 +106,7 @@ Summary: An interpreted, interactive, object-oriented programming language
Name: %{python}
# Remember to also rebase python-docs when changing this:
Version: 2.7.4
-Release: 2%{?dist}
+Release: 3%{?dist}
License: Python
Group: Development/Languages
Requires: %{python}-libs%{?_isa} = %{version}-%{release}
@@ -779,6 +779,14 @@ Patch174: 00174-fix-for-usr-move.patch
# (rhbz#927358)
Patch175: 00175-fix-configure-Wformat.patch
+# 00176 #
+# Allow arbitrary timeout for Condition.wait, as reported in
+# https://bugzilla.redhat.com/show_bug.cgi?id=917709
+# Upstream doesn't want this: http://bugs.python.org/issue17748
+# But we have no better solution downstream yet, and since there is
+# no API breakage, we apply this patch.
+# Doesn't apply to Python 3, where this is fixed otherwise and works.
+Patch176: 00176-allow-arbitrary-timeout-in-condition-wait.patch
# (New patches go here ^^^)
#
@@ -1119,6 +1127,7 @@ mv Modules/cryptmodule.c Modules/_cryptmodule.c
%patch173 -p1
%patch174 -p1 -b .fix-for-usr-move
%patch175 -p1 -b .fix-configure-Wformat
+%patch176 -p1
# This shouldn't be necesarry, but is right now (2.2a3)
@@ -1951,6 +1960,9 @@ rm -fr %{buildroot}
# ======================================================
%changelog
+* Mon Apr 22 2013 Bohuslav Kabrda <bkabrda at redhat.com> - 2.7.4-3
+- Allow arbitrary timeout in Condition.wait (rhbz#917709).
+
* Thu Apr 11 2013 Kalev Lember <kalevlember at gmail.com> - 2.7.4-2
- Build with libdb 5.3 instead of libdb4
- Refreshed patches: 0 (config), 102 (lib64)
More information about the scm-commits
mailing list