summaryrefslogtreecommitdiff
path: root/python/progress.h
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2009-07-20 15:37:25 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2009-07-20 15:37:25 +0200
commit8f9c131d127a59e5ea4ce3eed8d96be1766399f0 (patch)
treee796847cae94cb1a1ca93339a085b395a981503f /python/progress.h
parent87f6d28c1555ee70da9dddb9625cea0c4d6ab9a5 (diff)
parent53f514317550cc09ad3c3fb9503be51d88e3d31d (diff)
downloadpython-apt-8f9c131d127a59e5ea4ce3eed8d96be1766399f0.tar.gz
* apt/progress/__init__.py:
- add update_status_full() that takes file_size/partial_size as additional callback arguments - add pulse_items() that takes a addtional "items" tuple that gives the user full access to the individual items that are fetched * python/progress.cc: - low level code for update_status_full and pulse_items() - better threading support * aptsources/distro.py: - fix indent error that causes incorrect sources.list additons (LP: #372224) * python/progress.cc: - fix crash in RunSimpleCallback() * apt/cache.py: - when the cache is run with a alternative rootdir, create required dirs/files automatically
Diffstat (limited to 'python/progress.h')
-rw-r--r--python/progress.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/python/progress.h b/python/progress.h
index 5ac67b1c..29243bfc 100644
--- a/python/progress.h
+++ b/python/progress.h
@@ -15,10 +15,27 @@
#include <apt-pkg/cdrom.h>
#include <Python.h>
+/* 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
+ * use a class attribute (with the same) name, allowing blocking and
+ * unblocking from different class methods.
+ * Py_BLOCK_THREADS and Py_UNBLOCK_THREADS do not define their own
+ * local variable but use the one provided by PyCbObj_BEGIN_ALLOW_THREADS
+ * and thus are the same as Py_BLOCK_THREADS and Py_UNBLOCK_THREADS.
+ */
+#define PyCbObj_BEGIN_ALLOW_THREADS \
+ _save = PyEval_SaveThread();
+#define PyCbObj_END_ALLOW_THREADS \
+ PyEval_RestoreThread(_save); \
+ _save = NULL;
+#define PyCbObj_BLOCK_THREADS Py_BLOCK_THREADS
+#define PyCbObj_UNBLOCK_THREADS Py_UNBLOCK_THREADS
class PyCallbackObj {
protected:
PyObject *callbackInst;
+ PyThreadState *_save;
public:
void setCallbackInst(PyObject *o) {