diff options
author | Willian Padovani Germano <wpgermano@gmail.com> | 2008-07-03 01:01:59 +0400 |
---|---|---|
committer | Willian Padovani Germano <wpgermano@gmail.com> | 2008-07-03 01:01:59 +0400 |
commit | 424141f44d1c971455d7d207ad386d1fcd7d854b (patch) | |
tree | 81a6bdc8fc0039d44de842ff120f9eecb705a18d /source/blender/python | |
parent | 8ca128414ddbe73bf31755df6cf19e5c70aba99c (diff) |
== 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.
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/BPY_interface.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c index 2f94e0eeebc..226657655fa 100644 --- a/source/blender/python/BPY_interface.c +++ b/source/blender/python/BPY_interface.c @@ -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 ); |