From 9fa44c4a7c9ba0b856858b268445bd0f87ee58ae Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 23 Nov 2007 19:43:52 +0100 Subject: * python/depcache.cc: - be more threading friendly --- python/depcache.cc | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'python') diff --git a/python/depcache.cc b/python/depcache.cc index 94ff708c..f44f2f32 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -227,17 +227,19 @@ static PyObject *PkgDepCacheGetCandidateVer(PyObject *Self,PyObject *Args) static PyObject *PkgDepCacheUpgrade(PyObject *Self,PyObject *Args) { + bool res; pkgDepCache *depcache = GetCpp(Self); char distUpgrade=0; if (PyArg_ParseTuple(Args,"|b",&distUpgrade) == 0) return 0; - bool res; + Py_BEGIN_ALLOW_THREADS if(distUpgrade) res = pkgDistUpgrade(*depcache); else res = pkgAllUpgrade(*depcache); + Py_END_ALLOW_THREADS Py_INCREF(Py_None); return HandleErrors(Py_BuildValue("b",res)); @@ -245,12 +247,15 @@ static PyObject *PkgDepCacheUpgrade(PyObject *Self,PyObject *Args) static PyObject *PkgDepCacheMinimizeUpgrade(PyObject *Self,PyObject *Args) { + bool res; pkgDepCache *depcache = GetCpp(Self); if (PyArg_ParseTuple(Args,"") == 0) return 0; - bool res = pkgMinimizeUpgrade(*depcache); + Py_BEGIN_ALLOW_THREADS + res = pkgMinimizeUpgrade(*depcache); + Py_END_ALLOW_THREADS Py_INCREF(Py_None); return HandleErrors(Py_BuildValue("b",res)); @@ -351,8 +356,10 @@ static PyObject *PkgDepCacheMarkInstall(PyObject *Self,PyObject *Args) &autoInst, &fromUser) == 0) return 0; + Py_BEGIN_ALLOW_THREADS pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); depcache->MarkInstall(Pkg, autoInst, 0, fromUser); + Py_END_ALLOW_THREADS Py_INCREF(Py_None); return HandleErrors(Py_None); @@ -652,23 +659,31 @@ PyObject *GetPkgProblemResolver(PyObject *Self,PyObject *Args) static PyObject *PkgProblemResolverResolve(PyObject *Self,PyObject *Args) { + bool res; pkgProblemResolver *fixer = GetCpp(Self); char brokenFix=1; if (PyArg_ParseTuple(Args,"|b",&brokenFix) == 0) return 0; - bool res = fixer->Resolve(brokenFix); + Py_BEGIN_ALLOW_THREADS + res = fixer->Resolve(brokenFix); + Py_END_ALLOW_THREADS return HandleErrors(Py_BuildValue("b", res)); } static PyObject *PkgProblemResolverResolveByKeep(PyObject *Self,PyObject *Args) -{ +{ + bool res; pkgProblemResolver *fixer = GetCpp(Self); if (PyArg_ParseTuple(Args,"") == 0) return 0; - bool res = fixer->ResolveByKeep(); + + Py_BEGIN_ALLOW_THREADS + res = fixer->ResolveByKeep(); + Py_END_ALLOW_THREADS + return HandleErrors(Py_BuildValue("b", res)); } -- cgit v1.2.3