From 53e86d1f7a530f989047966061d0e7214ec529d2 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Wed, 14 Feb 2007 02:15:19 +0000 Subject: 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 --- pjsip-apps/src/py_pjsua/py_pjsua.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'pjsip-apps/src/py_pjsua') 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); } -- cgit v1.2.3