changeset 36361:a2d11d23bb25

patches: release the GIL while applying the patch This will allow multiple threads to apply patches at the same time.
author Boris Feld <boris.feld@octobus.net>
date Mon, 05 Feb 2018 15:03:51 +0100
parents c25290b98190
children 01e29e885600
files mercurial/cext/mpatch.c
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cext/mpatch.c	Wed Feb 21 11:43:12 2018 +0100
+++ b/mercurial/cext/mpatch.c	Mon Feb 05 15:03:51 2018 +0100
@@ -109,7 +109,13 @@
 		goto cleanup;
 	}
 	out = PyBytes_AsString(result);
-	r = mpatch_apply(out, in, inlen, patch);
+	/* clang-format off */
+	{
+		Py_BEGIN_ALLOW_THREADS
+		r = mpatch_apply(out, in, inlen, patch);
+		Py_END_ALLOW_THREADS
+	}
+	/* clang-format on */
 	if (r < 0) {
 		Py_DECREF(result);
 		result = NULL;