Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abc
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
abc
Commits
16e12f18
Commit
16e12f18
authored
Sep 29, 2011
by
Baruch Sterin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pyabc: fix callbacks into python to work correctly by moving to PyGILEState_Ensure/Release APIs
parent
ef0fbf03
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
17 deletions
+23
-17
src/python/pyabc.i
+23
-17
No files found.
src/python/pyabc.i
View file @
16e12f18
...
@@ -262,8 +262,6 @@ void pyabc_internal_set_command_callback( PyObject* callback )
...
@@ -262,8 +262,6 @@ void pyabc_internal_set_command_callback( PyObject* callback )
pyabc_internal_python_command_callback = callback;
pyabc_internal_python_command_callback = callback;
}
}
PyThreadState *_save;
static int pyabc_internal_abc_command_callback(Abc_Frame_t * pAbc, int argc, char ** argv)
static int pyabc_internal_abc_command_callback(Abc_Frame_t * pAbc, int argc, char ** argv)
{
{
int i;
int i;
...
@@ -271,13 +269,15 @@ static int pyabc_internal_abc_command_callback(Abc_Frame_t * pAbc, int argc, cha
...
@@ -271,13 +269,15 @@ static int pyabc_internal_abc_command_callback(Abc_Frame_t * pAbc, int argc, cha
PyObject* args;
PyObject* args;
PyObject* arglist;
PyObject* arglist;
PyObject* res;
PyObject* res;
PyGILState_STATE gstate;
long lres;
long lres;
if ( !pyabc_internal_python_command_callback )
if ( !pyabc_internal_python_command_callback )
return 0;
return 0;
Py_BLOCK_THREADS
gstate = PyGILState_Ensure();
args = PyList_New(argc);
args = PyList_New(argc);
...
@@ -292,14 +292,14 @@ static int pyabc_internal_abc_command_callback(Abc_Frame_t * pAbc, int argc, cha
...
@@ -292,14 +292,14 @@ static int pyabc_internal_abc_command_callback(Abc_Frame_t * pAbc, int argc, cha
if ( !res )
if ( !res )
{
{
Py
_UNBLOCK_THREADS
Py
GILState_Release(gstate);
return -1;
return -1;
}
}
lres = PyInt_AsLong(res);
lres = PyInt_AsLong(res);
Py_DECREF(res);
Py_DECREF(res);
Py
_UNBLOCK_THREADS
Py
GILState_Release(gstate);
return lres;
return lres;
}
}
...
@@ -309,11 +309,11 @@ int run_command(char* cmd)
...
@@ -309,11 +309,11 @@ int run_command(char* cmd)
Abc_Frame_t* pAbc = Abc_FrameGetGlobalFrame();
Abc_Frame_t* pAbc = Abc_FrameGetGlobalFrame();
int rc;
int rc;
Py_
UNBLOCK
_THREADS
Py_
BEGIN_ALLOW
_THREADS
rc = Cmd_CommandExecute(pAbc, cmd);
rc = Cmd_CommandExecute(pAbc, cmd);
Py_
BLOCK
_THREADS
Py_
END_ALLOW
_THREADS
return rc;
return rc;
}
}
...
@@ -401,13 +401,15 @@ int Util_SignalSystem(const char* cmd)
...
@@ -401,13 +401,15 @@ int Util_SignalSystem(const char* cmd)
{
{
PyObject* arglist;
PyObject* arglist;
PyObject* res;
PyObject* res;
PyGILState_STATE gstate;
long lres;
long lres;
if ( !pyabc_internal_system_callback )
if ( !pyabc_internal_system_callback )
return -1;
return -1;
Py_BLOCK_THREADS
gstate = PyGILState_Ensure();
arglist = Py_BuildValue("(O)", PyString_FromString(cmd));
arglist = Py_BuildValue("(O)", PyString_FromString(cmd));
Py_INCREF(arglist);
Py_INCREF(arglist);
...
@@ -417,14 +419,14 @@ int Util_SignalSystem(const char* cmd)
...
@@ -417,14 +419,14 @@ int Util_SignalSystem(const char* cmd)
if ( !res )
if ( !res )
{
{
Py
_UNBLOCK_THREADS
Py
GILState_Release(gstate);
return -1;
return -1;
}
}
lres = PyInt_AsLong(res);
lres = PyInt_AsLong(res);
Py_DECREF(res);
Py_DECREF(res);
Py
_UNBLOCK_THREADS
Py
GILState_Release(gstate);
return lres;
return lres;
}
}
...
@@ -437,12 +439,14 @@ int Util_SignalTmpFile(const char* prefix, const char* suffix, char** out_name)
...
@@ -437,12 +439,14 @@ int Util_SignalTmpFile(const char* prefix, const char* suffix, char** out_name)
PyObject* arglist;
PyObject* arglist;
PyObject* res;
PyObject* res;
PyGILState_STATE gstate;
*out_name = NULL;
*out_name = NULL;
if ( !pyabc_internal_tmpfile_callback )
if ( !pyabc_internal_tmpfile_callback )
return 0;
return 0;
Py_BLOCK_THREADS
gstate = PyGILState_Ensure();
arglist = Py_BuildValue("(ss)", prefix, suffix);
arglist = Py_BuildValue("(ss)", prefix, suffix);
Py_INCREF(arglist);
Py_INCREF(arglist);
...
@@ -452,7 +456,7 @@ int Util_SignalTmpFile(const char* prefix, const char* suffix, char** out_name)
...
@@ -452,7 +456,7 @@ int Util_SignalTmpFile(const char* prefix, const char* suffix, char** out_name)
if ( !res )
if ( !res )
{
{
Py
_UNBLOCK_THREADS
Py
GILState_Release(gstate);
return -1;
return -1;
}
}
...
@@ -463,7 +467,7 @@ int Util_SignalTmpFile(const char* prefix, const char* suffix, char** out_name)
...
@@ -463,7 +467,7 @@ int Util_SignalTmpFile(const char* prefix, const char* suffix, char** out_name)
Py_DECREF(res);
Py_DECREF(res);
Py
_UNBLOCK_THREADS
Py
GILState_Release(gstate);
return open(*out_name, O_WRONLY);
return open(*out_name, O_WRONLY);
}
}
...
@@ -472,11 +476,13 @@ void Util_SignalTmpFileRemove(const char* fname, int fLeave)
...
@@ -472,11 +476,13 @@ void Util_SignalTmpFileRemove(const char* fname, int fLeave)
{
{
PyObject* arglist;
PyObject* arglist;
PyObject* res;
PyObject* res;
PyGILState_STATE gstate;
if ( !pyabc_internal_tmpfile_remove_callback )
if ( !pyabc_internal_tmpfile_remove_callback )
return;
return;
Py_BLOCK_THREADS
gstate = PyGILState_Ensure();
arglist = Py_BuildValue("(si)", fname, fLeave);
arglist = Py_BuildValue("(si)", fname, fLeave);
Py_INCREF(arglist);
Py_INCREF(arglist);
...
@@ -485,7 +491,7 @@ void Util_SignalTmpFileRemove(const char* fname, int fLeave)
...
@@ -485,7 +491,7 @@ void Util_SignalTmpFileRemove(const char* fname, int fLeave)
Py_DECREF(arglist);
Py_DECREF(arglist);
Py_XDECREF(res);
Py_XDECREF(res);
Py
_UNBLOCK_THREADS
Py
GILState_Release(gstate);
}
}
void pyabc_internal_set_util_callbacks( PyObject* system_callback, PyObject* tmpfile_callback, PyObject* tmpfile_remove_callback )
void pyabc_internal_set_util_callbacks( PyObject* system_callback, PyObject* tmpfile_callback, PyObject* tmpfile_remove_callback )
...
@@ -1045,7 +1051,7 @@ def cmd_python(cmd_args):
...
@@ -1045,7 +1051,7 @@ def cmd_python(cmd_args):
usage = "usage: %prog [options] <Python files>"
usage = "usage: %prog [options] <Python files>"
parser = optparse.OptionParser(usage)
parser = optparse.OptionParser(usage
, prog="python"
)
parser.add_option("-c", "--cmd", dest="cmd", help="Execute Python command directly")
parser.add_option("-c", "--cmd", dest="cmd", help="Execute Python command directly")
parser.add_option("-v", "--version", action="store_true", dest="version", help="Display Python Version")
parser.add_option("-v", "--version", action="store_true", dest="version", help="Display Python Version")
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment