[xiph-commits] r14340 - icecast/trunk/shout-python

msmith at svn.xiph.org msmith at svn.xiph.org
Fri Jan 4 04:00:55 PST 2008


Author: msmith
Date: 2008-01-04 04:00:53 -0800 (Fri, 04 Jan 2008)
New Revision: 14340

Modified:
   icecast/trunk/shout-python/shout.c
Log:
Patch from Andrey Petrov: drop GIL around potentially blocking libshout methods.


Modified: icecast/trunk/shout-python/shout.c
===================================================================
--- icecast/trunk/shout-python/shout.c	2008-01-03 15:18:52 UTC (rev 14339)
+++ icecast/trunk/shout-python/shout.c	2008-01-04 12:00:53 UTC (rev 14340)
@@ -385,11 +385,16 @@
 static PyObject* pshoutobj_send(ShoutObject* self, PyObject* args) {
   const unsigned char* data;
   size_t len;
+  int res;
 
   if (!PyArg_ParseTuple(args, "s#", &data, &len))
     return NULL;
 
-  if (shout_send(self->conn, data, len) != SHOUTERR_SUCCESS) {
+  Py_BEGIN_ALLOW_THREADS
+  res = shout_send(self->conn, data, len);
+  Py_END_ALLOW_THREADS
+
+  if (res != SHOUTERR_SUCCESS) { 
     PyErr_SetString(ShoutError, shout_get_error(self->conn));
 
     return NULL;
@@ -399,7 +404,9 @@
 }
 
 static PyObject* pshoutobj_sync(ShoutObject* self) {
+  Py_BEGIN_ALLOW_THREADS
   shout_sync(self->conn);
+  Py_END_ALLOW_THREADS
 
   return Py_BuildValue("i", 1);
 }



More information about the commits mailing list