diff options
| author | Stephan Peijnik <debian@sp.or.at> | 2009-07-03 13:16:27 +0200 |
|---|---|---|
| committer | Stephan Peijnik <debian@sp.or.at> | 2009-07-03 13:16:27 +0200 |
| commit | 2e2d8f93cdcfc61655bc0895380b33cfa4c78e9f (patch) | |
| tree | 9f3cd4ec2977ac5f4693a8883166529ca6a9a974 | |
| parent | 4882fc138b9439469bb934f2db659bc97f131725 (diff) | |
| parent | 59b0a9ccf0b81a0a13ed10f4ceee28b24cfbb85c (diff) | |
| download | python-apt-2e2d8f93cdcfc61655bc0895380b33cfa4c78e9f.tar.gz | |
Further work on threading support.
Fixed bug that prevented building with Python 2.4.
| -rw-r--r-- | debian/changelog | 1 | ||||
| -rw-r--r-- | po/python-apt.pot | 2 | ||||
| -rw-r--r-- | python/generic.h | 3 | ||||
| -rw-r--r-- | python/progress.cc | 15 | ||||
| -rw-r--r-- | python/progress.h | 6 |
5 files changed, 22 insertions, 5 deletions
diff --git a/debian/changelog b/debian/changelog index 0f9463b2..db6204ba 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,7 @@ python-apt (0.7.10.4) UNRELEASED; urgency=low fetched * python/progress.cc: - low level code for update_status_full and pulse_items() + - better threading support -- Michael Vogt <michael.vogt@ubuntu.com> Tue, 05 May 2009 11:57:57 +0200 diff --git a/po/python-apt.pot b/po/python-apt.pot index 2a004600..02120bfa 100644 --- a/po/python-apt.pot +++ b/po/python-apt.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-05-05 11:44+0200\n" +"POT-Creation-Date: 2009-07-03 12:55+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" diff --git a/python/generic.h b/python/generic.h index ce79a54c..d2fcf42a 100644 --- a/python/generic.h +++ b/python/generic.h @@ -121,8 +121,9 @@ void CppOwnedDealloc(PyObject *iObj) { CppOwnedPyObject<T> *Obj = (CppOwnedPyObject<T> *)iObj; Obj->Object.~T(); - if (Obj->Owner != 0) + if (Obj->Owner != 0) { Py_DECREF(Obj->Owner); + } PyObject_DEL(Obj); } diff --git a/python/progress.cc b/python/progress.cc index 027a51b4..cbb49671 100644 --- a/python/progress.cc +++ b/python/progress.cc @@ -336,15 +336,19 @@ bool PyFetchProgress::Pulse(pkgAcquire * Owner) void PyInstallProgress::StartUpdate() { RunSimpleCallback("startUpdate"); + PyCbObj_BEGIN_ALLOW_THREADS } void PyInstallProgress::UpdateInterface() { + PyCbObj_END_ALLOW_THREADS RunSimpleCallback("updateInterface"); + PyCbObj_BEGIN_ALLOW_THREADS } void PyInstallProgress::FinishUpdate() { + PyCbObj_END_ALLOW_THREADS RunSimpleCallback("finishUpdate"); } @@ -403,9 +407,9 @@ pkgPackageManager::OrderResult PyInstallProgress::Run(pkgPackageManager *pm) _exit(res); } - StartUpdate(); + PyCbObj_END_ALLOW_THREADS if(PyObject_HasAttrString(callbackInst, "waitChild")) { PyObject *method = PyObject_GetAttrString(callbackInst, "waitChild"); //std::cerr << "custom waitChild found" << std::endl; @@ -420,14 +424,19 @@ pkgPackageManager::OrderResult PyInstallProgress::Run(pkgPackageManager *pm) int child_res; if(!PyArg_Parse(result, "i", &res) ) { std::cerr << "custom waitChild() result could not be parsed?"<< std::endl; + PyCbObj_BEGIN_ALLOW_THREADS return pkgPackageManager::Failed; } + PyCbObj_BEGIN_ALLOW_THREADS //std::cerr << "got child_res: " << res << std::endl; } else { //std::cerr << "using build-in waitpid()" << std::endl; - - while (waitpid(child_id, &ret, WNOHANG) == 0) + PyCbObj_BEGIN_ALLOW_THREADS + while (waitpid(child_id, &ret, WNOHANG) == 0) { + PyCbObj_END_ALLOW_THREADS UpdateInterface(); + PyCbObj_BEGIN_ALLOW_THREADS + } res = (pkgPackageManager::OrderResult) WEXITSTATUS(ret); //std::cerr << "build-in waitpid() got: " << res << std::endl; diff --git a/python/progress.h b/python/progress.h index 29243bfc..659eb113 100644 --- a/python/progress.h +++ b/python/progress.h @@ -15,6 +15,12 @@ #include <apt-pkg/cdrom.h> #include <Python.h> +/* Python 2.4 compatibility */ +#if (PY_VERSION_HEX < 0x02050000) +typedef int Py_ssize_t; +#endif + + /* PyCbObj_BEGIN_ALLOW_THREADS and PyCbObj_END_ALLOW_THREADS are sligthly * modified versions of Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS. * Instead of storing the thread state in a function-local variable these |
