It is safe to use python threads in Blender, and they don't have to stop when the script exists.<div><br><div>Just when the py thread touches blender data it needs to be threadsafe.  When its not touching blender data, it can run freely, for example send some data over a pipe or socket.  And this will help performance since the sendall on the socket releases the GIL, and won't block blender.</div>
<div><br>How to make the thread "know" when its safe to touch blender data, you can use the redraw callback hack, in the future the locking would be better done with ideasman's new patch that allows for python callbacks on post_depgraph update.</div>
<div><meta http-equiv="content-type" content="text/html; charset=utf-8"><a href="http://pastebin.com/HgCWmLHh">http://pastebin.com/HgCWmLHh</a></div><div><br></div><div>-brett</div><div><br></div><div><br><div class="gmail_quote">
On Sat, Aug 27, 2011 at 2:58 AM, Campbell Barton <span dir="ltr"><<a href="mailto:ideasman42@gmail.com">ideasman42@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Update - added a section on unicode problems<br>
<br>
<a href="http://www.blender.org/documentation/blender_python_api_2_59_0/info_gotcha.html#unicode-problems" target="_blank">http://www.blender.org/documentation/blender_python_api_2_59_0/info_gotcha.html#unicode-problems</a><br>

<div class="im"><br>
On Fri, Aug 26, 2011 at 4:55 PM, bartius crouch<br>
<<a href="mailto:bartius.crouch@gmail.com">bartius.crouch@gmail.com</a>> wrote:<br>
> Very useful document. People who use the bpy api a lot are probably<br>
</div>> already aware of these points.<br>
<br>
For the basics, sure, But to write the docs I had to do read up on<br>
python docs and do tests myself to double check the docs were<br>
accurate, even exposed a few bugs in pythons api including a crash -<br>
issue IMHO is some parts of the api experienced py devs avoid because<br>
they give problems but that also means they don't get tested properly<br>
and new scripters can run into them.<br>
<div class="im"><br>
> but I think especially the last part on memory re-allocation is very useful for people who are wondering why<br>
> their script is crashing.<br>
><br>
> Bart<br>
<br>
</div>--<br>
<font color="#888888">- Campbell<br>
</font><div><div></div><div class="h5">_______________________________________________<br>
Bf-python mailing list<br>
<a href="mailto:Bf-python@blender.org">Bf-python@blender.org</a><br>
<a href="http://lists.blender.org/mailman/listinfo/bf-python" target="_blank">http://lists.blender.org/mailman/listinfo/bf-python</a><br>
</div></div></blockquote></div><br></div></div>