Rev 1512: Release GIL in a couple more places. in file:///data/jelmer/bzr-svn/gil/

Jelmer Vernooij jelmer at samba.org
Fri Aug 1 22:06:44 BST 2008


At file:///data/jelmer/bzr-svn/gil/

------------------------------------------------------------
revno: 1512
revision-id: jelmer at samba.org-20080801210643-kpnl7bgu22gosalb
parent: jelmer at samba.org-20080801205549-tfdd1gq00pq6nn1e
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: gil
timestamp: Fri 2008-08-01 23:06:43 +0200
message:
  Release GIL in a couple more places.
modified:
  editor.c                       editor.c-20080602191336-frj7az1sdk13o1tw-1
  ra.c                           ra.pyx-20080313140933-qybkqaxe3m4mcll7-1
  util.h                         util.h-20080531154025-s8ef6ej9tytsnkkw-2
=== modified file 'editor.c'
--- a/editor.c	2008-07-30 05:51:22 +0000
+++ b/editor.c	2008-08-01 21:06:43 +0000
@@ -61,14 +61,14 @@
 	PyObject *py_window, *py_ops, *py_new_data;
 	int i;
 	svn_string_t new_data;
+	svn_error_t *error;
 	svn_txdelta_op_t *ops;
 
 	if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwnames, &py_window))
 		return NULL;
 
 	if (py_window == Py_None) {
-		if (!check_error(obj->txdelta_handler(NULL, obj->txdelta_baton)))
-			return NULL;
+		RUN_SVN(obj->txdelta_handler(NULL, obj->txdelta_baton));
 		Py_RETURN_NONE;
 	}
 
@@ -100,7 +100,10 @@
 		}
 	}
 
-	if (!check_error(obj->txdelta_handler(&window, obj->txdelta_baton))) {
+	Py_BEGIN_ALLOW_THREADS
+	error = obj->txdelta_handler(&window, obj->txdelta_baton);
+	Py_END_ALLOW_THREADS
+	if (!check_error(error)) {
 		free(ops);
 		return NULL;
 	}
@@ -153,10 +156,9 @@
 
 	if (!PyArg_ParseTuple(args, "|z", &c_base_checksum))
 		return NULL;
-	if (!check_error(editor->editor->apply_textdelta(editor->baton,
+	RUN_SVN(editor->editor->apply_textdelta(editor->baton,
 				c_base_checksum, editor->pool, 
-				&txdelta_handler, &txdelta_baton)))
-		return NULL;
+				&txdelta_handler, &txdelta_baton));
 	py_txdelta = PyObject_New(TxDeltaWindowHandlerObject, &TxDeltaWindowHandler_Type);
 	py_txdelta->txdelta_handler = txdelta_handler;
 	py_txdelta->txdelta_baton = txdelta_baton;
@@ -176,9 +178,8 @@
 
 	if (!PyArg_ParseTuple(args, "sz#", &name, &c_value.data, &c_value.len))
 		return NULL;
-	if (!check_error(editor->editor->change_file_prop(editor->baton, name, 
-				&c_value, editor->pool)))
-		return NULL;
+	RUN_SVN(editor->editor->change_file_prop(editor->baton, name, 
+				&c_value, editor->pool));
 	Py_RETURN_NONE;
 }
 
@@ -194,9 +195,8 @@
 
 	if (!PyArg_ParseTuple(args, "|z", &c_checksum))
 		return NULL;
-	if (!check_error(editor->editor->close_file(editor->baton, c_checksum, 
-					editor->pool)))
-		return NULL;
+	RUN_SVN(editor->editor->close_file(editor->baton, c_checksum, 
+					editor->pool));
 	Py_RETURN_NONE;
 }
 
@@ -281,9 +281,8 @@
 	if (!PyArg_ParseTuple(args, "s|l", &path, &revision))
 		return NULL;
 
-	if (!check_error(editor->editor->delete_entry(path, revision, editor->baton,
-											 editor->pool)))
-		return NULL;
+	RUN_SVN(editor->editor->delete_entry(path, revision, editor->baton,
+											 editor->pool));
 
 	Py_RETURN_NONE;
 }
@@ -304,9 +303,8 @@
 	if (!PyArg_ParseTuple(args, "s|zl", &path, &copyfrom_path, &copyfrom_rev))
 		return NULL;
 
-	if (!check_error(editor->editor->add_directory(path, editor->baton,
-					copyfrom_path, copyfrom_rev, editor->pool, &child_baton)))
-		return NULL;
+	RUN_SVN(editor->editor->add_directory(path, editor->baton,
+					copyfrom_path, copyfrom_rev, editor->pool, &child_baton));
 
 	return new_editor_object(editor->editor, child_baton, editor->pool, 
 							 &DirectoryEditor_Type, NULL, NULL);
@@ -327,9 +325,8 @@
 	if (!PyArg_ParseTuple(args, "s|l", &path, &base_revision))
 		return NULL;
 
-	if (!check_error(editor->editor->open_directory(path, editor->baton,
-					base_revision, editor->pool, &child_baton)))
-		return NULL;
+	RUN_SVN(editor->editor->open_directory(path, editor->baton,
+					base_revision, editor->pool, &child_baton));
 
 	return new_editor_object(editor->editor, child_baton, editor->pool, 
 							 &DirectoryEditor_Type, NULL, NULL);
@@ -351,9 +348,8 @@
 
 	p_c_value = &c_value;
 
-	if (!check_error(editor->editor->change_dir_prop(editor->baton, name, 
-					p_c_value, editor->pool)))
-		return NULL;
+	RUN_SVN(editor->editor->change_dir_prop(editor->baton, name, 
+					p_c_value, editor->pool));
 
 	Py_RETURN_NONE;
 }
@@ -367,9 +363,7 @@
 		return NULL;
 	}
 
-	if (!check_error(editor->editor->close_directory(editor->baton, 
-													 editor->pool)))
-		return NULL;
+	RUN_SVN(editor->editor->close_directory(editor->baton, editor->pool));
 
 	Py_RETURN_NONE;
 }
@@ -388,9 +382,7 @@
 	if (!PyArg_ParseTuple(args, "s", &path))
 		return NULL;
 	
-	if (!check_error(editor->editor->absent_directory(path, editor->baton, 
-					editor->pool)))
-		return NULL;
+	RUN_SVN(editor->editor->absent_directory(path, editor->baton, editor->pool));
 
 	Py_RETURN_NONE;
 }
@@ -410,9 +402,8 @@
 	if (!PyArg_ParseTuple(args, "s|zl", &path, &copy_path, &copy_rev))
 		return NULL;
 
-	if (!check_error(editor->editor->add_file(path, editor->baton, copy_path,
-					copy_rev, editor->pool, &file_baton)))
-		return NULL;
+	RUN_SVN(editor->editor->add_file(path, editor->baton, copy_path,
+					copy_rev, editor->pool, &file_baton));
 
 	return new_editor_object(editor->editor, file_baton, editor->pool,
 							 &FileEditor_Type, NULL, NULL);
@@ -433,9 +424,8 @@
 	if (!PyArg_ParseTuple(args, "s|l", &path, &base_revision))
 		return NULL;
 
-	if (!check_error(editor->editor->open_file(path, editor->baton, 
-					base_revision, editor->pool, &file_baton)))
-		return NULL;
+	RUN_SVN(editor->editor->open_file(path, editor->baton, 
+					base_revision, editor->pool, &file_baton));
 
 	return new_editor_object(editor->editor, file_baton, editor->pool,
 							 &FileEditor_Type, NULL, NULL);
@@ -454,8 +444,7 @@
 	if (!PyArg_ParseTuple(args, "s", &path))
 		return NULL;
 
-	if (!check_error(editor->editor->absent_file(path, editor->baton, editor->pool)))
-		return NULL;
+	RUN_SVN(editor->editor->absent_file(path, editor->baton, editor->pool));
 
 	Py_RETURN_NONE;
 }
@@ -548,9 +537,8 @@
 	if (!PyArg_ParseTuple(args, "i", &target_revision))
 		return NULL;
 
-	if (!check_error(editor->editor->set_target_revision(editor->baton,
-					target_revision, editor->pool)))
-		return NULL;
+	RUN_SVN(editor->editor->set_target_revision(editor->baton,
+					target_revision, editor->pool));
 
 	Py_RETURN_NONE;
 }
@@ -569,9 +557,8 @@
 	if (!PyArg_ParseTuple(args, "|l:open_root", &base_revision))
 		return NULL;
 
-	if (!check_error(editor->editor->open_root(editor->baton, base_revision,
-					editor->pool, &root_baton)))
-		return NULL;
+	RUN_SVN(editor->editor->open_root(editor->baton, base_revision,
+					editor->pool, &root_baton));
 
 	return new_editor_object(editor->editor, root_baton, editor->pool,
 							 &DirectoryEditor_Type, NULL, NULL);
@@ -586,8 +573,7 @@
 		return NULL;
 	}
 
-	if (!check_error(editor->editor->close_edit(editor->baton, editor->pool)))
-		return NULL;
+	RUN_SVN(editor->editor->close_edit(editor->baton, editor->pool));
 
 	if (editor->done_cb != NULL)
 		editor->done_cb(editor->done_baton);
@@ -604,8 +590,7 @@
 		return NULL;
 	}
 
-	if (!check_error(editor->editor->abort_edit(editor->baton, editor->pool)))
-		return NULL;
+	RUN_SVN(editor->editor->abort_edit(editor->baton, editor->pool));
 
 	if (editor->done_cb != NULL)
 		editor->done_cb(editor->done_baton);

=== modified file 'ra.c'
--- a/ra.c	2008-08-01 20:55:49 +0000
+++ b/ra.c	2008-08-01 21:06:43 +0000
@@ -122,10 +122,9 @@
 						  &lock_token))
 		return NULL;
 
-	if (!check_error(reporter->reporter->set_path(reporter->report_baton, 
+	RUN_SVN(reporter->reporter->set_path(reporter->report_baton, 
 												  path, revision, start_empty, 
-					 lock_token, reporter->pool)))
-		return NULL;
+					 lock_token, reporter->pool));
 
 	Py_RETURN_NONE;
 }
@@ -137,9 +136,8 @@
 	if (!PyArg_ParseTuple(args, "s", &path))
 		return NULL;
 
-	if (!check_error(reporter->reporter->delete_path(reporter->report_baton, 
-													path, reporter->pool)))
-		return NULL;
+	RUN_SVN(reporter->reporter->delete_path(reporter->report_baton, 
+													path, reporter->pool));
 
 	Py_RETURN_NONE;
 }
@@ -155,9 +153,8 @@
 	if (!PyArg_ParseTuple(args, "sslb|z", &path, &url, &revision, &start_empty, &lock_token))
 		return NULL;
 
-	if (!check_error(reporter->reporter->link_path(reporter->report_baton, path, url, 
-				revision, start_empty, lock_token, reporter->pool)))
-		return NULL;
+	RUN_SVN(reporter->reporter->link_path(reporter->report_baton, path, url, 
+				revision, start_empty, lock_token, reporter->pool));
 
 	Py_RETURN_NONE;
 }
@@ -168,9 +165,8 @@
 
 	reporter->ra->busy = false;
 
-	if (!check_error(reporter->reporter->finish_report(reporter->report_baton, 
-													  reporter->pool)))
-		return NULL;
+	RUN_SVN(reporter->reporter->finish_report(reporter->report_baton, 
+													  reporter->pool));
 
 	Py_XDECREF(reporter->ra);
 
@@ -183,9 +179,8 @@
 	
 	reporter->ra->busy = false;
 
-	if (!check_error(reporter->reporter->abort_report(reporter->report_baton, 
-													 reporter->pool)))
-		return NULL;
+	RUN_SVN(reporter->reporter->abort_report(reporter->report_baton, 
+													 reporter->pool));
 
 	Py_XDECREF(reporter->ra);
 

=== modified file 'util.h'
--- a/util.h	2008-08-01 20:55:49 +0000
+++ b/util.h	2008-08-01 21:06:43 +0000
@@ -38,6 +38,17 @@
 svn_error_t *py_svn_error(void);
 void PyErr_SetSubversionException(svn_error_t *error);
 
+#define RUN_SVN(cmd) { \
+	svn_error_t *err; \
+	PyThreadState *_save; \
+	_save = PyEval_SaveThread(); \
+	err = (cmd); \
+	PyEval_RestoreThread(_save); \
+	if (!check_error(err)) { \
+		return NULL; \
+	} \
+}
+
 #define RUN_SVN_WITH_POOL(pool, cmd) { \
 	svn_error_t *err; \
 	PyThreadState *_save; \




More information about the bazaar-commits mailing list