[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15409] trunk/blender/source/blender/ python/BPY_interface.c: == Python, GE & Threads ==
Willian Padovani Germano
wpgermano at gmail.com
Wed Jul 2 23:02:06 CEST 2008
Revision: 15409
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15409
Author: ianwill
Date: 2008-07-02 23:01:59 +0200 (Wed, 02 Jul 2008)
Log Message:
-----------
== 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.
Modified Paths:
--------------
trunk/blender/source/blender/python/BPY_interface.c
Modified: trunk/blender/source/blender/python/BPY_interface.c
===================================================================
--- trunk/blender/source/blender/python/BPY_interface.c 2008-07-02 20:44:13 UTC (rev 15408)
+++ trunk/blender/source/blender/python/BPY_interface.c 2008-07-02 21:01:59 UTC (rev 15409)
@@ -229,13 +229,6 @@
/* 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 @@
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 @@
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 );
More information about the Bf-blender-cvs
mailing list