summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2007-02-14 02:15:19 +0000
committerBenny Prijono <bennylp@teluu.com>2007-02-14 02:15:19 +0000
commit53e86d1f7a530f989047966061d0e7214ec529d2 (patch)
treee2b17a7c6d46b3ab1f47b05692aae2c438238e2a
parent9ef0c7da71409115284b92764c4f748150745514 (diff)
Fixed ticket #93: Python readline() blocks/hang because C module running on different thread is calling a blocking OS call
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@945 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjsip-apps/src/py_pjsua/py_pjsua.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/pjsip-apps/src/py_pjsua/py_pjsua.c b/pjsip-apps/src/py_pjsua/py_pjsua.c
index cb370f1e..e5cb6caf 100644
--- a/pjsip-apps/src/py_pjsua/py_pjsua.c
+++ b/pjsip-apps/src/py_pjsua/py_pjsua.c
@@ -2163,7 +2163,15 @@ static PyObject *py_pjsua_handle_events(PyObject *pSelf, PyObject *pArgs)
{
return NULL;
}
+
+ /* Since handle_events() will block, we must wrap it with ALLOW_THREADS
+ * construct, or otherwise many Python blocking functions (such as
+ * time.sleep(), readline(), etc.) may hang/block indefinitely.
+ * See http://www.python.org/doc/current/api/threads.html for more info.
+ */
+ Py_BEGIN_ALLOW_THREADS
ret = pjsua_handle_events(msec);
+ Py_END_ALLOW_THREADS
return Py_BuildValue("i",ret);
}