forked from bartvdbraak/blender
== Python, GE & Threads ==
Martin Sell (thanks!) reported that threading via scripts was not working in the game engine with Blender 2.46 and later. My fault, to make pynodes work properly with threads > 1 I disabled Python's "check interval", preventing threads created via scripts from receiving time to run. Now only during rendering check interval is disabled (set to max int). Still experimental, I added the calls in BPY_do_all_scripts, since it's called in BIF_do_render, but will probably move the code to its own function after more testing & feedback.
This commit is contained in:
parent
8ca128414d
commit
424141f44d
@ -229,13 +229,6 @@ void BPY_start_python( int argc, char **argv )
|
||||
/* Initialize thread support (also acquires lock) */
|
||||
PyEval_InitThreads();
|
||||
|
||||
/* Don't allow the Python Interpreter to release the GIL on
|
||||
* its own, to guarantee PyNodes work properly. For Blender this
|
||||
* is currently the best default behavior.
|
||||
* The following code in C is equivalent in Python to:
|
||||
* "import sys; sys.setcheckinterval(sys.maxint)" */
|
||||
_Py_CheckInterval = PyInt_GetMax();
|
||||
|
||||
//Overrides __import__
|
||||
init_ourImport( );
|
||||
init_ourReload( );
|
||||
@ -2188,6 +2181,18 @@ void BPY_do_all_scripts( short event )
|
||||
|
||||
BPY_do_pyscript( &( G.scene->id ), event );
|
||||
|
||||
/* Don't allow the Python Interpreter to release the GIL on
|
||||
* its own, to guarantee PyNodes work properly. For Blender this
|
||||
* is currently the best default behavior.
|
||||
* The following code in C is equivalent in Python to:
|
||||
* "import sys; sys.setcheckinterval(sys.maxint)" */
|
||||
if (event == SCRIPT_RENDER) {
|
||||
_Py_CheckInterval = PyInt_GetMax();
|
||||
}
|
||||
else if (event == SCRIPT_POSTRENDER) {
|
||||
_Py_CheckInterval = 100; /* Python default */
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2270,9 +2275,9 @@ void BPY_do_pyscript( ID * id, short event )
|
||||
return;
|
||||
}
|
||||
|
||||
/* tell we're running a scriptlink. The sum also tells if this script
|
||||
* is running nested inside another. Blender.Load needs this info to
|
||||
* avoid trouble with invalid slink pointers. */
|
||||
/* tell we're running a scriptlink. The sum also tells if this
|
||||
* script is running nested inside another. Blender.Load needs
|
||||
* this info to avoid trouble with invalid slink pointers. */
|
||||
during_slink++;
|
||||
disable_where_scriptlink( (short)during_slink );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user