Rev 1508: Deal with GIL in a couple of places. in file:///data/jelmer/bzr-svn/gil/
Jelmer Vernooij
jelmer at samba.org
Fri Aug 1 21:04:52 BST 2008
At file:///data/jelmer/bzr-svn/gil/
------------------------------------------------------------
revno: 1508
revision-id: jelmer at samba.org-20080801200449-blxkcn5d330avho3
parent: jelmer at samba.org-20080731013015-2xxjwktdc20v3dhv
author: Mark Hammond <mhammond at skippinet.com.au>
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: gil
timestamp: Fri 2008-08-01 22:04:49 +0200
message:
Deal with GIL in a couple of places.
modified:
ra.c ra.pyx-20080313140933-qybkqaxe3m4mcll7-1
=== modified file 'ra.c'
--- a/ra.c 2008-07-30 10:42:53 +0000
+++ b/ra.c 2008-08-01 20:04:49 +0000
@@ -41,17 +41,20 @@
static svn_error_t *py_commit_callback(const svn_commit_info_t *commit_info, void *baton, apr_pool_t *pool)
{
PyObject *fn = (PyObject *)baton, *ret;
-
- if (fn == Py_None)
- return NULL;
-
- ret = PyObject_CallFunction(fn, "izz",
- commit_info->revision, commit_info->date,
- commit_info->author);
- if (ret == NULL)
- return py_svn_error();
- Py_DECREF(ret);
- return NULL;
+ PyGILState_STATE state = PyGILState_Ensure();
+ svn_error_t *err = NULL;
+
+ if (fn != Py_None) {
+ ret = PyObject_CallFunction(fn, "izz",
+ commit_info->revision, commit_info->date,
+ commit_info->author);
+ if (ret == NULL)
+ err = py_svn_error();
+ else
+ Py_DECREF(ret);
+ }
+ PyGILState_Release(state);
+ return err;
}
static PyObject *pyify_lock(const svn_lock_t *lock)
@@ -659,14 +662,15 @@
static void py_progress_func(apr_off_t progress, apr_off_t total, void *baton, apr_pool_t *pool)
{
+ PyGILState_STATE state = PyGILState_Ensure();
RemoteAccessObject *ra = (RemoteAccessObject *)baton;
PyObject *fn = (PyObject *)ra->progress_func, *ret;
- if (fn == Py_None) {
- return;
+ if (fn != Py_None) {
+ ret = PyObject_CallFunction(fn, "LL", progress, total);
+ /* TODO: What to do with exceptions raised here ? */
+ Py_XDECREF(ret);
}
- ret = PyObject_CallFunction(fn, "LL", progress, total);
- /* TODO: What to do with exceptions raised here ? */
- Py_XDECREF(ret);
+ PyGILState_Release(state);
}
static PyObject *ra_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
@@ -682,6 +686,7 @@
apr_hash_t *config_hash;
svn_ra_callbacks2_t *callbacks2;
svn_auth_baton_t *auth_baton;
+ svn_error_t *err;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|OOOOO", kwnames, &url, &progress_cb,
(PyObject **)&auth, &config, &client_string_func,
@@ -731,8 +736,11 @@
PyObject_Del(ret);
return NULL;
}
- if (!check_error(svn_ra_open2(&ret->ra, apr_pstrdup(ret->pool, url),
- callbacks2, ret, config_hash, ret->pool))) {
+ Py_BEGIN_ALLOW_THREADS
+ err = svn_ra_open2(&ret->ra, apr_pstrdup(ret->pool, url),
+ callbacks2, ret, config_hash, ret->pool);
+ Py_END_ALLOW_THREADS
+ if (!check_error(err)) {
apr_pool_destroy(ret->pool);
PyObject_Del(ret);
return NULL;
More information about the bazaar-commits
mailing list