patches: release the GIL while applying the patch
authorBoris Feld <boris.feld@octobus.net>
Mon, 05 Feb 2018 15:03:51 +0100
changeset 36361 a2d11d23bb25
parent 36360 c25290b98190
child 36362 01e29e885600
patches: release the GIL while applying the patch This will allow multiple threads to apply patches at the same time.
mercurial/cext/mpatch.c
--- 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;