Release the global interpreter lock around the most important

functions that might block or pause
This commit is contained in:
Andrew M. Kuchling 2000-06-23 01:36:21 +00:00
parent 8d929aee49
commit f419572708
1 changed files with 45 additions and 12 deletions

View File

@ -633,12 +633,16 @@ PyCursesWindow_GetCh(self,arg)
switch (ARG_COUNT(arg)) { switch (ARG_COUNT(arg)) {
case 0: case 0:
Py_BEGIN_ALLOW_THREADS
rtn = wgetch(self->win); rtn = wgetch(self->win);
Py_END_ALLOW_THREADS
break; break;
case 2: case 2:
if (!PyArg_Parse(arg,"(ii);y,x",&y,&x)) if (!PyArg_Parse(arg,"(ii);y,x",&y,&x))
return NULL; return NULL;
Py_BEGIN_ALLOW_THREADS
rtn = mvwgetch(self->win,y,x); rtn = mvwgetch(self->win,y,x);
Py_END_ALLOW_THREADS
break; break;
default: default:
PyErr_SetString(PyExc_TypeError, "getch requires 0 or 2 arguments"); PyErr_SetString(PyExc_TypeError, "getch requires 0 or 2 arguments");
@ -657,12 +661,16 @@ PyCursesWindow_GetKey(self,arg)
switch (ARG_COUNT(arg)) { switch (ARG_COUNT(arg)) {
case 0: case 0:
Py_BEGIN_ALLOW_THREADS
rtn = wgetch(self->win); rtn = wgetch(self->win);
Py_END_ALLOW_THREADS
break; break;
case 2: case 2:
if (!PyArg_Parse(arg,"(ii);y,x",&y,&x)) if (!PyArg_Parse(arg,"(ii);y,x",&y,&x))
return NULL; return NULL;
Py_BEGIN_ALLOW_THREADS
rtn = mvwgetch(self->win,y,x); rtn = mvwgetch(self->win,y,x);
Py_END_ALLOW_THREADS
break; break;
default: default:
PyErr_SetString(PyExc_TypeError, "getkey requires 0 or 2 arguments"); PyErr_SetString(PyExc_TypeError, "getkey requires 0 or 2 arguments");
@ -685,27 +693,37 @@ PyCursesWindow_GetStr(self,arg)
switch (ARG_COUNT(arg)) { switch (ARG_COUNT(arg)) {
case 0: case 0:
Py_BEGIN_ALLOW_THREADS
rtn2 = wgetstr(self->win,rtn); rtn2 = wgetstr(self->win,rtn);
Py_END_ALLOW_THREADS
break; break;
case 1: case 1:
if (!PyArg_Parse(arg,"i;n", &n)) if (!PyArg_Parse(arg,"i;n", &n))
return NULL; return NULL;
Py_BEGIN_ALLOW_THREADS
rtn2 = wgetnstr(self->win,rtn,n); rtn2 = wgetnstr(self->win,rtn,n);
Py_END_ALLOW_THREADS
break; break;
case 2: case 2:
if (!PyArg_Parse(arg,"(ii);y,x",&y,&x)) if (!PyArg_Parse(arg,"(ii);y,x",&y,&x))
return NULL; return NULL;
Py_BEGIN_ALLOW_THREADS
rtn2 = mvwgetstr(self->win,y,x,rtn); rtn2 = mvwgetstr(self->win,y,x,rtn);
Py_END_ALLOW_THREADS
break; break;
case 3: case 3:
if (!PyArg_Parse(arg,"(iii);y,x,n", &y, &x, &n)) if (!PyArg_Parse(arg,"(iii);y,x,n", &y, &x, &n))
return NULL; return NULL;
#if defined(__sgi__) || defined(__sun__) #if defined(__sgi__) || defined(__sun__)
/* Untested */ /* Untested */
Py_BEGIN_ALLOW_THREADS
rtn2 = wmove(self->win,y,x)==ERR ? ERR : rtn2 = wmove(self->win,y,x)==ERR ? ERR :
wgetnstr(self->win, rtn, n); wgetnstr(self->win, rtn, n);
Py_END_ALLOW_THREADS
#else #else
Py_BEGIN_ALLOW_THREADS
rtn2 = mvwgetnstr(self->win, y, x, rtn, n); rtn2 = mvwgetnstr(self->win, y, x, rtn, n);
Py_END_ALLOW_THREADS
#endif #endif
break; break;
default: default:
@ -996,6 +1014,7 @@ PyCursesWindow_NoOutRefresh(self,arg)
PyObject * arg; PyObject * arg;
{ {
int pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol; int pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol;
int rtn;
if (self->win->_flags & _ISPAD) { if (self->win->_flags & _ISPAD) {
switch(ARG_COUNT(arg)) { switch(ARG_COUNT(arg)) {
@ -1006,20 +1025,26 @@ PyCursesWindow_NoOutRefresh(self,arg)
&pminrow, &pmincol, &sminrow, &pminrow, &pmincol, &sminrow,
&smincol, &smaxrow, &smaxcol)) &smincol, &smaxrow, &smaxcol))
return NULL; return NULL;
return PyCursesCheckERR(pnoutrefresh(self->win, Py_BEGIN_ALLOW_THREADS
pminrow, pmincol, sminrow, rtn = pnoutrefresh(self->win,
smincol, smaxrow, smaxcol), pminrow, pmincol, sminrow,
"pnoutrefresh"); smincol, smaxrow, smaxcol),
Py_END_ALLOW_THREADS
return PyCursesCheckERR(rtn, "pnoutrefresh");
default: default:
PyErr_SetString(PyCursesError, PyErr_SetString(PyCursesError,
"noutrefresh was called for a pad;" \ "noutrefresh() called for a pad "
"requires 6 arguments"); "requires 6 arguments");
return NULL; return NULL;
} }
} else { } else {
if (!PyArg_NoArgs(arg)) if (!PyArg_NoArgs(arg))
return NULL; return NULL;
return PyCursesCheckERR(wnoutrefresh(self->win), "wnoutrefresh");
Py_BEGIN_ALLOW_THREADS
rtn = wnoutrefresh(self->win);
Py_END_ALLOW_THREADS
return PyCursesCheckERR(rtn, "wnoutrefresh");
} }
} }
@ -1057,6 +1082,7 @@ PyCursesWindow_Refresh(self,arg)
PyObject * arg; PyObject * arg;
{ {
int pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol; int pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol;
int rtn;
if (self->win->_flags & _ISPAD) { if (self->win->_flags & _ISPAD) {
switch(ARG_COUNT(arg)) { switch(ARG_COUNT(arg)) {
@ -1067,19 +1093,26 @@ PyCursesWindow_Refresh(self,arg)
&pminrow, &pmincol, &sminrow, &pminrow, &pmincol, &sminrow,
&smincol, &smaxrow, &smaxcol)) &smincol, &smaxrow, &smaxcol))
return NULL; return NULL;
return PyCursesCheckERR(prefresh(self->win,
pminrow, pmincol, sminrow, Py_BEGIN_ALLOW_THREADS
smincol, smaxrow, smaxcol), rtn = prefresh(self->win,
"prefresh"); pminrow, pmincol, sminrow,
smincol, smaxrow, smaxcol),
Py_END_ALLOW_THREADS
return PyCursesCheckERR(rtn, "prefresh");
default: default:
PyErr_SetString(PyCursesError, PyErr_SetString(PyCursesError,
"refresh was called for a pad; requires 6 arguments"); "refresh() for a pad requires 6 arguments");
return NULL; return NULL;
} }
} else { } else {
if (!PyArg_NoArgs(arg)) if (!PyArg_NoArgs(arg))
return NULL; return NULL;
return PyCursesCheckERR(wrefresh(self->win), "wrefresh"); Py_BEGIN_ALLOW_THREADS
rtn = wrefresh(self->win);
Py_END_ALLOW_THREADS
return PyCursesCheckERR(rtn);
} }
} }